diff --git a/libgrive/src/base/Resource.cc b/libgrive/src/base/Resource.cc index 66a4ac3..1058e16 100644 --- a/libgrive/src/base/Resource.cc +++ b/libgrive/src/base/Resource.cc @@ -463,7 +463,7 @@ void Resource::SyncSelf( Syncer* syncer, ResourceTree *res_tree, const Val& opti if ( syncer ) { if ( is_local ) - syncer->Move( from, to->Parent(), to->Name() ); + syncer->Move( from, to ); else { fs::rename( from->Path(), to->Path() ); diff --git a/libgrive/src/base/Syncer.hh b/libgrive/src/base/Syncer.hh index 29de4b9..9f05102 100644 --- a/libgrive/src/base/Syncer.hh +++ b/libgrive/src/base/Syncer.hh @@ -53,7 +53,7 @@ public : virtual void Download( Resource *res, const fs::path& file ); virtual bool EditContent( Resource *res, bool new_rev ) = 0; virtual bool Create( Resource *res ) = 0; - virtual bool Move( Resource* res, Resource* newParent, std::string newFilename ) = 0; + virtual bool Move( Resource* res, Resource* newRes ) = 0; virtual std::auto_ptr GetFolders() = 0; virtual std::auto_ptr GetAll() = 0; diff --git a/libgrive/src/drive2/Syncer2.cc b/libgrive/src/drive2/Syncer2.cc index 66ad64f..320a049 100644 --- a/libgrive/src/drive2/Syncer2.cc +++ b/libgrive/src/drive2/Syncer2.cc @@ -89,7 +89,7 @@ bool Syncer2::Create( Resource *res ) return Upload( res ); } -bool Syncer2::Move( Resource* res, Resource* newParentRes, std::string newFilename ) +bool Syncer2::Move( Resource* res, Resource* newRes ) { if ( res->ResourceID().empty() ) { @@ -98,7 +98,7 @@ bool Syncer2::Move( Resource* res, Resource* newParentRes, std::string newFilena } Val meta; - meta.Add( "title", Val(newFilename) ); + meta.Add( "title", Val( newRes->Name() ) ); if ( res->IsFolder() ) { meta.Add( "mimeType", Val( mime_types::folder ) ); @@ -110,14 +110,14 @@ bool Syncer2::Move( Resource* res, Resource* newParentRes, std::string newFilena // Issue metadata update request { std::string addRemoveParents(""); - if (res->Parent()->IsRoot() ) + if ( res->Parent()->IsRoot() ) addRemoveParents += "&removeParents=root"; else addRemoveParents += "&removeParents=" + res->Parent()->ResourceID(); - if ( newParentRes->IsRoot() ) + if ( newRes->Parent()->IsRoot() ) addRemoveParents += "&addParents=root"; else - addRemoveParents += "&addParents=" + newParentRes->ResourceID(); + addRemoveParents += "&addParents=" + newRes->Parent()->ResourceID(); http::Header hdr2 ; hdr2.Add( "Content-Type: application/json" ); http::ValResponse vrsp ; @@ -128,6 +128,9 @@ bool Syncer2::Move( Resource* res, Resource* newParentRes, std::string newFilena ) ; valr = vrsp.Response(); assert( http_code == 200 && !( valr["id"].Str().empty() ) ); + Entry2 responseEntry = Entry2( valr ) ; + AssignIDs( newRes, responseEntry ) ; + newRes->SetServerTime( responseEntry.MTime() ); } return true; diff --git a/libgrive/src/drive2/Syncer2.hh b/libgrive/src/drive2/Syncer2.hh index 96f93fc..81c48d3 100644 --- a/libgrive/src/drive2/Syncer2.hh +++ b/libgrive/src/drive2/Syncer2.hh @@ -37,7 +37,7 @@ public : void DeleteRemote( Resource *res ); bool EditContent( Resource *res, bool new_rev ); bool Create( Resource *res ); - bool Move( Resource* res, Resource* newParent, std::string newFilename ); + bool Move( Resource* res, Resource* newRes ); std::auto_ptr GetFolders(); std::auto_ptr GetAll();