From cbf40e9b90b38abf25c3ebfeb7488c52b30170b9 Mon Sep 17 00:00:00 2001 From: Nestal Wan Date: Tue, 5 Jun 2012 00:59:14 +0800 Subject: [PATCH] fixed uninitialized change stamp --- grive/src/main.cc | 8 ++++---- libgrive/src/drive/Drive.cc | 15 +++++++++------ libgrive/src/drive/State.cc | 3 ++- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/grive/src/main.cc b/grive/src/main.cc index bdb127f..0ad12e3 100644 --- a/grive/src/main.cc +++ b/grive/src/main.cc @@ -160,10 +160,10 @@ int main( int argc, char **argv ) OAuth2 token( refresh_token, client_id, client_secret ) ; Drive drive( token, options ) ; -// drive.Update() ; -// drive.SaveState() ; -// -// config.Save() ; + drive.Update() ; + drive.SaveState() ; + + config.Save() ; } catch ( gr::Exception& e ) { diff --git a/libgrive/src/drive/Drive.cc b/libgrive/src/drive/Drive.cc index e54d6a7..a3270ab 100644 --- a/libgrive/src/drive/Drive.cc +++ b/libgrive/src/drive/Drive.cc @@ -91,12 +91,15 @@ Drive::Drive( OAuth2& auth, const Json& options ) : } while ( feed.GetNext( &http, m_http_hdr ) ) ; // pull the changes feed - boost::format changes_uri( "https://docs.google.com/feeds/default/private/changes?start-index=%1%" ) ; - http::ResponseLog log2( "changes-", ".xml", &xrsp ) ; - http.Get( (changes_uri%(prev_stamp+1)).str(), &log2, m_http_hdr ) ; - - Feed changes( xrsp.Response() ) ; - std::for_each( changes.begin(), changes.end(), boost::bind( &Drive::FromChange, this, _1 ) ) ; + if ( prev_stamp != -1 ) + { + boost::format changes_uri( "https://docs.google.com/feeds/default/private/changes?start-index=%1%" ) ; + http::ResponseLog log2( "changes-", ".xml", &xrsp ) ; + http.Get( (changes_uri%(prev_stamp+1)).str(), &log2, m_http_hdr ) ; + + Feed changes( xrsp.Response() ) ; + std::for_each( changes.begin(), changes.end(), boost::bind( &Drive::FromChange, this, _1 ) ) ; + } } void Drive::FromRemote( const Entry& entry ) diff --git a/libgrive/src/drive/State.cc b/libgrive/src/drive/State.cc index 0939302..a6ff6b9 100644 --- a/libgrive/src/drive/State.cc +++ b/libgrive/src/drive/State.cc @@ -39,7 +39,8 @@ namespace gr { -State::State( const fs::path& filename, const Json& options ) +State::State( const fs::path& filename, const Json& options ) : + m_cstamp( -1 ) { Read( filename ) ;