From 34be2e7a8701f51b52c0ea3242c28ed2d80b613d Mon Sep 17 00:00:00 2001 From: Georges Dubus Date: Wed, 27 Jun 2012 14:17:13 +0200 Subject: [PATCH] Fixed a bug where grive crashed on the first run. It gived a negative start index to get the changes feed, which is illegal. The error returned by the server triggered a crash. Fixes #76. --- libgrive/src/drive/Drive.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libgrive/src/drive/Drive.cc b/libgrive/src/drive/Drive.cc index 66ffaad..d2c8a9c 100644 --- a/libgrive/src/drive/Drive.cc +++ b/libgrive/src/drive/Drive.cc @@ -188,8 +188,17 @@ void Drive::UpdateChangeStamp( http::Agent *http ) http::XmlResponse xrsp ; // get changed feed - boost::format changes_uri( "https://docs.google.com/feeds/default/private/changes?start-index=%1%" ) ; - http->Get( (changes_uri%(m_state.ChangeStamp()+1)).str(), &xrsp, m_http_hdr ) ; + std::string url; + if (m_state.ChangeStamp() != -1) + { + boost::format changes_uri( "https://docs.google.com/feeds/default/private/changes?start-index=%1%" ) ; + url = (changes_uri%(m_state.ChangeStamp()+1)).str(); + } + else + { + url = "https://docs.google.com/feeds/default/private/changes"; + } + http->Get( url, &xrsp, m_http_hdr ) ; // we should go through the changes to see if it was really Grive to made that change // maybe by recording the updated timestamp and compare it?