added more log for dry-run (#65)

pull/40/head
Nestal Wan 2012-06-17 16:33:38 +08:00
parent 55ac367255
commit 48391bb16f
6 changed files with 32 additions and 16 deletions

View File

@ -178,6 +178,8 @@ int Main( int argc, char **argv )
drive.Update() ;
drive.SaveState() ;
}
else
drive.DryRun() ;
config.Save() ;
Log( "Finished!", log::info ) ;

View File

@ -178,4 +178,10 @@ void Drive::Update()
m_state.Sync( &http, m_http_hdr ) ;
}
void Drive::DryRun()
{
Log( "Synchronizing files (dry-run)", log::info ) ;
m_state.Sync( 0, m_http_hdr ) ;
}
} // end of namespace

View File

@ -44,7 +44,7 @@ public :
Drive( OAuth2& auth, const Json& options ) ;
void Update() ;
void Sync() ;
void DryRun() ;
void SaveState() ;
struct Error : virtual Exception {} ;

View File

@ -370,41 +370,49 @@ void Resource::SyncSelf( http::Agent* http, const http::Header& auth )
case local_new :
Log( "sync %1% doesn't exist in server, uploading", path, log::info ) ;
if ( Create( http, auth ) )
if ( http != 0 && Create( http, auth ) )
m_state = sync ;
break ;
case local_deleted :
Log( "sync %1% deleted in local. deleting remote", path, log::info ) ;
DeleteRemote( http, auth ) ;
if ( http != 0 )
DeleteRemote( http, auth ) ;
break ;
case local_changed :
Log( "sync %1% changed in local. uploading", path, log::info ) ;
if ( EditContent( http, auth ) )
if ( http != 0 && EditContent( http, auth ) )
m_state = sync ;
break ;
case remote_new :
Log( "sync %1% created in remote. creating local", path, log::info ) ;
if ( IsFolder() )
fs::create_directories( path ) ;
else
Download( http, path, auth ) ;
m_state = sync ;
if ( http != 0 )
{
if ( IsFolder() )
fs::create_directories( path ) ;
else
Download( http, path, auth ) ;
m_state = sync ;
}
break ;
case remote_changed :
assert( !IsFolder() ) ;
Log( "sync %1% changed in remote. downloading", path, log::info ) ;
Download( http, path, auth ) ;
m_state = sync ;
if ( http != 0 )
{
Download( http, path, auth ) ;
m_state = sync ;
}
break ;
case remote_deleted :
Log( "sync %1% deleted in remote. deleting local", path, log::info ) ;
DeleteLocal() ;
if ( http != 0 )
DeleteLocal() ;
break ;
case sync :
@ -446,6 +454,7 @@ void Resource::DeleteLocal()
void Resource::DeleteRemote( http::Agent *http, const http::Header& auth )
{
assert( http != 0 ) ;
http::StringResponse str ;
try

View File

@ -73,6 +73,7 @@ void State::FromLocal( const fs::path& p, gr::Resource* folder )
for ( fs::directory_iterator i( p ) ; i != fs::directory_iterator() ; ++i )
{
std::string fname = Path2Str(i->path().filename()) ;
// Trace( "found file %1%", i->path() ) ;
if ( IsIgnore(fname) )
Log( "file %1% is ignored by grive", fname, log::verbose ) ;

View File

@ -23,14 +23,12 @@
#include <memory>
#include <string>
#include <vector>
namespace gr { namespace http {
class Receivable ;
/*! \class Agent
\brief class to provide HTTP access
/*! \brief agent to provide HTTP access
This class provides functions to send HTTP request in many methods (e.g. get, post and put).
Normally the HTTP response is returned in a Receivable.