diff --git a/libgrive/src/drive/Drive.cc b/libgrive/src/drive/Drive.cc index e1b7d63..9fc3fb5 100644 --- a/libgrive/src/drive/Drive.cc +++ b/libgrive/src/drive/Drive.cc @@ -97,10 +97,18 @@ Drive::Drive( OAuth2& auth ) : if ( file.Kind() != "folder" ) { Resource *p = m_state.FindFolderByHref( file.ParentHref() ) ; - if ( p != 0 && p->IsInRootTree() ) - m_state.OnEntry( file ) ; - else + if ( file.Filename().empty() ) + Log( "file \"%1%\" is a google document, ignored", file.Title() ) ; + + else if ( file.ParentHref().empty() || p == 0 || !p->IsInRootTree() ) Log( "file \"%1%\" parent doesn't exist, ignored", file.Title() ) ; + + else if ( p != 0 && !p->IsFolder() ) + Log( "entry %1% has parent %2% which is not a folder, ignored", + file.Title(), p->Name() ) ; + + else + m_state.OnEntry( file ) ; } } diff --git a/libgrive/src/drive/State.cc b/libgrive/src/drive/State.cc index cae3ee6..e2598b8 100644 --- a/libgrive/src/drive/State.cc +++ b/libgrive/src/drive/State.cc @@ -81,7 +81,7 @@ void State::Sync( const fs::path& p, gr::Resource* folder ) } else if ( i->path().filename().string()[0] != '.' ) { -Trace( "file: %1% %2%", i->path().filename().string(), folder->Path() ) ; +// Trace( "file: %1% %2%", i->path().filename().string(), folder->Path() ) ; Resource *c = new Resource( i->path().filename().string(), "file", "" ) ; folder->AddChild( c ) ; m_folders.Insert( c ) ; @@ -141,25 +141,13 @@ std::size_t State::TryResolveEntry() bool State::Update( const Entry& e ) { - if ( e.Kind() != "folder" && e.Filename().empty() ) - { - Log( "file \"%1%\" is a google document, ignored", e.Title() ) ; - return true ; - } - - if ( e.ParentHref().empty() ) - { - Log( "\"%1%\" has no parent, ignored", e.Title() ) ; - return true ; - } + assert( !e.ParentHref().empty() ) ; Resource *parent = m_folders.FindByHref( e.ParentHref() ) ; if ( parent != 0 ) { -if ( !parent->IsFolder() ) -Trace( "name = \"%1%\" \"%2%\"", e.Title(), parent->Name() ) ; assert( parent->IsFolder() ) ; - + // see if the entry already exist in local Resource *child = parent->FindChild( e.Title() ) ; if ( child != 0 )