Skip to content
Browse files

store modified time of file in m_mtime instead of passing value as param

  • Loading branch information...
1 parent c12029a commit 94a83243ccf331359ade17fc6121ed63c7e5a3da justin committed
Showing with 17 additions and 15 deletions.
  1. +13 −11 libgrive/src/drive/Resource.cc
  2. +4 −4 libgrive/src/drive/Resource.hh
View
24 libgrive/src/drive/Resource.cc
@@ -370,7 +370,10 @@ void Resource::Sync( http::Agent *http, DateTime& sync_time )
assert( m_state != unknown ) ;
assert( !IsRoot() || m_state == sync ) ; // root folder is already synced
- SyncSelf( http, sync_time ) ;
+ SyncSelf( http ) ;
+ // we want the server sync time, so we will take the server time of the last file uploaded to store as the sync time
+ // m_mtime is updated to server modified time when the file is uploaded
+ sync_time = std::max(sync_time, m_mtime);
// if myself is deleted, no need to do the childrens
if ( m_state != local_deleted && m_state != remote_deleted )
@@ -378,7 +381,7 @@ void Resource::Sync( http::Agent *http, DateTime& sync_time )
boost::bind( &Resource::Sync, _1, http, boost::ref(sync_time) ) ) ;
}
-void Resource::SyncSelf( http::Agent* http, DateTime& sync_time )
+void Resource::SyncSelf( http::Agent* http )
{
assert( !IsRoot() || m_state == sync ) ; // root is always sync
assert( IsRoot() || http == 0 || fs::is_directory( m_parent->Path() ) ) ;
@@ -392,7 +395,7 @@ void Resource::SyncSelf( http::Agent* http, DateTime& sync_time )
case local_new :
Log( "sync %1% doesn't exist in server, uploading", path, log::info ) ;
- if ( http != 0 && Create( http, sync_time ) )
+ if ( http != 0 && Create( http ) )
m_state = sync ;
break ;
@@ -404,7 +407,7 @@ void Resource::SyncSelf( http::Agent* http, DateTime& sync_time )
case local_changed :
Log( "sync %1% changed in local. uploading", path, log::info ) ;
- if ( http != 0 && EditContent( http, sync_time ) )
+ if ( http != 0 && EditContent( http ) )
m_state = sync ;
break ;
@@ -517,7 +520,7 @@ void Resource::Download( http::Agent* http, const fs::path& file ) const
}
}
-bool Resource::EditContent( http::Agent* http, DateTime& sync_time )
+bool Resource::EditContent( http::Agent* http )
{
assert( http != 0 ) ;
assert( m_parent != 0 ) ;
@@ -530,10 +533,10 @@ bool Resource::EditContent( http::Agent* http, DateTime& sync_time )
return false ;
}
- return Upload( http, m_edit, false, sync_time ) ;
+ return Upload( http, m_edit, false ) ;
}
-bool Resource::Create( http::Agent* http, DateTime& sync_time )
+bool Resource::Create( http::Agent* http)
{
assert( http != 0 ) ;
assert( m_parent != 0 ) ;
@@ -563,7 +566,7 @@ bool Resource::Create( http::Agent* http, DateTime& sync_time )
}
else if ( !m_parent->m_create.empty() )
{
- return Upload( http, m_parent->m_create + "?convert=false", true, sync_time ) ;
+ return Upload( http, m_parent->m_create + "?convert=false", true ) ;
}
else
{
@@ -575,8 +578,7 @@ bool Resource::Create( http::Agent* http, DateTime& sync_time )
bool Resource::Upload(
http::Agent* http,
const std::string& link,
- bool post,
- DateTime& sync_time )
+ bool post)
{
assert( http != 0 ) ;
@@ -612,7 +614,7 @@ bool Resource::Upload(
http->Put( uplink, file, &xml, uphdr ) ;
AssignIDs( Entry( xml.Response() ) ) ;
- sync_time = std::max(Entry(xml.Response()).MTime(), sync_time);
+ m_mtime = Entry(xml.Response()).MTime();
return true ;
}
View
8 libgrive/src/drive/Resource.hh
@@ -124,9 +124,9 @@ private :
void SetState( State new_state ) ;
void Download( http::Agent* http, const fs::path& file ) const ;
- bool EditContent( http::Agent* http, DateTime& sync_time ) ;
- bool Create( http::Agent* http, DateTime& sync_time ) ;
- bool Upload( http::Agent* http, const std::string& link, bool post, DateTime& sync_time ) ;
+ bool EditContent( http::Agent* http ) ;
+ bool Create( http::Agent* http ) ;
+ bool Upload( http::Agent* http, const std::string& link, bool post ) ;
void FromRemoteFolder( const Entry& remote, const DateTime& last_sync ) ;
void FromRemoteFile( const Entry& remote, const DateTime& last_sync ) ;
@@ -135,7 +135,7 @@ private :
void DeleteRemote( http::Agent* http ) ;
void AssignIDs( const Entry& remote ) ;
- void SyncSelf( http::Agent* http, DateTime& sync_time ) ;
+ void SyncSelf( http::Agent* http ) ;
private :
std::string m_name ;

0 comments on commit 94a8324

Please sign in to comment.
Something went wrong with that request. Please try again.