pull/286/merge
Gianluca Recchia 2021-12-26 07:56:55 +03:30 committed by GitHub
commit 843c7e6093
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 5 deletions

View File

@ -79,13 +79,13 @@ bool Syncer2::Create( Resource *res )
assert( res->Parent()->IsFolder() ) ; assert( res->Parent()->IsFolder() ) ;
assert( res->Parent()->GetState() == Resource::sync ) ; assert( res->Parent()->GetState() == Resource::sync ) ;
assert( res->ResourceID().empty() ) ; assert( res->ResourceID().empty() ) ;
if ( !res->Parent()->IsEditable() ) if ( !res->Parent()->IsEditable() )
{ {
Log( "Cannot upload %1%: parent directory read-only. %2%", res->Name(), res->StateStr(), log::warning ) ; Log( "Cannot upload %1%: parent directory read-only. %2%", res->Name(), res->StateStr(), log::warning ) ;
return false ; return false ;
} }
return Upload( res, false ); return Upload( res, false );
} }
@ -122,7 +122,10 @@ bool Syncer2::Move( Resource* res, Resource* newParentRes, std::string newFilena
hdr2.Add( "Content-Type: application/json" ); hdr2.Add( "Content-Type: application/json" );
http::ValResponse vrsp ; http::ValResponse vrsp ;
// Don't change modified date because we're only moving // Don't change modified date because we're only moving
long http_code = m_http->Put( #ifndef NDEBUG
const long http_code =
#endif
m_http->Put(
feeds::files + "/" + res->ResourceID() + "?modifiedDateBehavior=noChange" + addRemoveParents, feeds::files + "/" + res->ResourceID() + "?modifiedDateBehavior=noChange" + addRemoveParents,
json_meta, &vrsp, hdr2 json_meta, &vrsp, hdr2
) ; ) ;
@ -164,11 +167,19 @@ bool Syncer2::Upload( Resource *res, bool new_rev )
http::Header hdr2 ; http::Header hdr2 ;
hdr2.Add( "Content-Type: application/json" ); hdr2.Add( "Content-Type: application/json" );
http::ValResponse vrsp ; http::ValResponse vrsp ;
#ifndef NDEBUG
long http_code = 0; long http_code = 0;
#endif
if ( res->ResourceID().empty() ) if ( res->ResourceID().empty() )
http_code = m_http->Post( feeds::files, json_meta, &vrsp, hdr2 ) ; #ifndef NDEBUG
http_code =
#endif
m_http->Post( feeds::files, json_meta, &vrsp, hdr2 ) ;
else else
http_code = m_http->Put( feeds::files + "/" + res->ResourceID(), json_meta, &vrsp, hdr2 ) ; #ifndef NDEBUG
http_code =
#endif
m_http->Put( feeds::files + "/" + res->ResourceID(), json_meta, &vrsp, hdr2 ) ;
valr = vrsp.Response(); valr = vrsp.Response();
assert( http_code == 200 && !( valr["id"].Str().empty() ) ); assert( http_code == 200 && !( valr["id"].Str().empty() ) );
} }