From 1d1365ea1af2766795c6b34d6767e3c047b50689 Mon Sep 17 00:00:00 2001 From: Nestal Wan Date: Sat, 23 Jun 2012 18:23:43 +0800 Subject: [PATCH] refactored code in Update() to DetectChanges() --- grive/src/main.cc | 1 + libgrive/src/drive/Drive.cc | 12 +++++++----- libgrive/src/drive/Drive.hh | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/grive/src/main.cc b/grive/src/main.cc index aa713c2..d51e0d9 100644 --- a/grive/src/main.cc +++ b/grive/src/main.cc @@ -173,6 +173,7 @@ int Main( int argc, char **argv ) OAuth2 token( refresh_token, client_id, client_secret ) ; Drive drive( token, options ) ; + drive.DetectChanges() ; if ( vm.count( "dry-run" ) == 0 ) { diff --git a/libgrive/src/drive/Drive.cc b/libgrive/src/drive/Drive.cc index 5ca5b6f..4d9695c 100644 --- a/libgrive/src/drive/Drive.cc +++ b/libgrive/src/drive/Drive.cc @@ -59,7 +59,6 @@ Drive::Drive( OAuth2& auth, const Json& options ) : { m_http_hdr.Add( "Authorization: Bearer " + m_auth.AccessToken() ) ; m_http_hdr.Add( "GData-Version: 3.0" ) ; - } void Drive::FromRemote( const Entry& entry ) @@ -129,7 +128,7 @@ void Drive::SyncFolders( http::Agent *http ) m_state.ResolveEntry() ; } -void Drive::Update() +void Drive::DetectChanges() { Log( "Reading local directories", log::info ) ; m_state.FromLocal( "." ) ; @@ -172,9 +171,12 @@ void Drive::Update() std::for_each( changes.begin(), changes.end(), boost::bind( &Drive::FromChange, this, _1 ) ) ; } 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() diff --git a/libgrive/src/drive/Drive.hh b/libgrive/src/drive/Drive.hh index 2a51c60..a3c91f8 100644 --- a/libgrive/src/drive/Drive.hh +++ b/libgrive/src/drive/Drive.hh @@ -43,6 +43,7 @@ class Drive public : Drive( OAuth2& auth, const Json& options ) ; + void DetectChanges() ; void Update() ; void DryRun() ; void SaveState() ;