mirror of https://github.com/vitalif/grive2
fixed handling on changes feed.
parent
dbf0ae4be0
commit
277274f026
|
@ -175,6 +175,7 @@ int Main( int argc, char **argv )
|
|||
drive.SaveState() ;
|
||||
|
||||
config.Save() ;
|
||||
Log( "Finished!", log::info ) ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
|
@ -187,10 +188,14 @@ int main( int argc, char **argv )
|
|||
catch ( Exception& e )
|
||||
{
|
||||
Log( "exception: %1%", boost::diagnostic_information(e), log::critical ) ;
|
||||
return -1 ;
|
||||
}
|
||||
catch ( std::exception& e )
|
||||
{
|
||||
Log( "exception: %1%", e.what(), log::critical ) ;
|
||||
}
|
||||
catch ( ... )
|
||||
{
|
||||
Log( "unexpected exception", log::critical ) ;
|
||||
}
|
||||
return -1 ;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ Drive::Drive( OAuth2& auth, const Json& options ) :
|
|||
http::CurlAgent http ;
|
||||
|
||||
long prev_stamp = m_state.ChangeStamp() ;
|
||||
Trace( "previous time stamp is %1%", prev_stamp ) ;
|
||||
|
||||
// get metadata
|
||||
http::XmlResponse xrsp ;
|
||||
|
@ -115,24 +116,6 @@ void Drive::FromRemote( const Entry& entry )
|
|||
else if ( parent == 0 || !parent->IsInRootTree() )
|
||||
Log( "file \"%1%\" parent doesn't exist, ignored", entry.Title(), log::verbose ) ;
|
||||
|
||||
else
|
||||
FromEntry( entry ) ;
|
||||
}
|
||||
|
||||
void Drive::FromEntry( const Entry& entry )
|
||||
{
|
||||
std::string fn = entry.Filename() ;
|
||||
|
||||
// common checkings
|
||||
if ( fn.empty() || entry.ContentSrc().empty() )
|
||||
Log( "file \"%1%\" is a google document, ignored", entry.Title(), log::verbose ) ;
|
||||
|
||||
else if ( fn.find('/') != fn.npos )
|
||||
Log( "file \"%1%\" contains a slash in its name, ignored", entry.Title(), log::verbose ) ;
|
||||
|
||||
else if ( entry.ParentHrefs().size() != 1 )
|
||||
Log( "file \"%1%\" has multiple parents, ignored", entry.Title(), log::verbose ) ;
|
||||
|
||||
else
|
||||
m_state.FromRemote( entry ) ;
|
||||
}
|
||||
|
@ -142,8 +125,10 @@ void Drive::FromChange( const Entry& entry )
|
|||
if ( entry.IsRemoved() )
|
||||
Log( "file \"%1%\" represents a deletion, ignored", entry.Title(), log::verbose ) ;
|
||||
|
||||
// folders go directly
|
||||
|
||||
else
|
||||
FromEntry( entry ) ;
|
||||
m_state.FromRemote( entry ) ;
|
||||
}
|
||||
|
||||
void Drive::SaveState()
|
||||
|
|
|
@ -52,7 +52,6 @@ public :
|
|||
private :
|
||||
void SyncFolders( http::Agent *http ) ;
|
||||
void file();
|
||||
void FromEntry( const Entry& entry ) ;
|
||||
void FromRemote( const Entry& entry ) ;
|
||||
void FromChange( const Entry& entry ) ;
|
||||
|
||||
|
|
|
@ -103,9 +103,21 @@ void State::FromLocal( const fs::path& p, gr::Resource* folder )
|
|||
|
||||
void State::FromRemote( const Entry& e )
|
||||
{
|
||||
std::string fn = e.Filename() ;
|
||||
|
||||
if ( IsIgnore( e.Name() ) )
|
||||
Log( "%1% %2% is ignored by grive", e.Kind(), e.Name(), log::verbose ) ;
|
||||
|
||||
// common checkings
|
||||
else if ( e.Kind() != "folder" && (fn.empty() || e.ContentSrc().empty()) )
|
||||
Log( "%1% \"%2%\" is a google document, ignored", e.Kind(), e.Name(), log::verbose ) ;
|
||||
|
||||
else if ( fn.find('/') != fn.npos )
|
||||
Log( "%1% \"%2%\" contains a slash in its name, ignored", e.Kind(), e.Name(), log::verbose ) ;
|
||||
|
||||
else if ( !e.IsChange() && e.ParentHrefs().size() != 1 )
|
||||
Log( "%1% \"%2%\" has multiple parents, ignored", e.Kind(), e.Name(), log::verbose ) ;
|
||||
|
||||
else if ( e.IsChange() )
|
||||
FromChange( e ) ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue