refactored code in Update() to DetectChanges()

pull/40/head
Nestal Wan 2012-06-23 18:23:43 +08:00
parent 62238c5ba6
commit 1d1365ea1a
3 changed files with 9 additions and 5 deletions

View File

@ -173,6 +173,7 @@ int Main( int argc, char **argv )
OAuth2 token( refresh_token, client_id, client_secret ) ; OAuth2 token( refresh_token, client_id, client_secret ) ;
Drive drive( token, options ) ; Drive drive( token, options ) ;
drive.DetectChanges() ;
if ( vm.count( "dry-run" ) == 0 ) if ( vm.count( "dry-run" ) == 0 )
{ {

View File

@ -59,7 +59,6 @@ Drive::Drive( OAuth2& auth, const Json& options ) :
{ {
m_http_hdr.Add( "Authorization: Bearer " + m_auth.AccessToken() ) ; m_http_hdr.Add( "Authorization: Bearer " + m_auth.AccessToken() ) ;
m_http_hdr.Add( "GData-Version: 3.0" ) ; m_http_hdr.Add( "GData-Version: 3.0" ) ;
} }
void Drive::FromRemote( const Entry& entry ) void Drive::FromRemote( const Entry& entry )
@ -129,7 +128,7 @@ void Drive::SyncFolders( http::Agent *http )
m_state.ResolveEntry() ; m_state.ResolveEntry() ;
} }
void Drive::Update() void Drive::DetectChanges()
{ {
Log( "Reading local directories", log::info ) ; Log( "Reading local directories", log::info ) ;
m_state.FromLocal( "." ) ; m_state.FromLocal( "." ) ;
@ -172,9 +171,12 @@ void Drive::Update()
std::for_each( changes.begin(), changes.end(), boost::bind( &Drive::FromChange, this, _1 ) ) ; std::for_each( changes.begin(), changes.end(), boost::bind( &Drive::FromChange, this, _1 ) ) ;
} }
Log( "Synchronizing files", log::info ) ; Log( "Synchronizing files", log::info ) ;
}
http::CurlAgent http2 ;
m_state.Sync( &http2, m_http_hdr ) ; void Drive::Update()
{
http::CurlAgent http ;
m_state.Sync( &http, m_http_hdr ) ;
} }
void Drive::DryRun() void Drive::DryRun()

View File

@ -43,6 +43,7 @@ class Drive
public : public :
Drive( OAuth2& auth, const Json& options ) ; Drive( OAuth2& auth, const Json& options ) ;
void DetectChanges() ;
void Update() ; void Update() ;
void DryRun() ; void DryRun() ;
void SaveState() ; void SaveState() ;