improved checking on files

pull/40/head
Matchman Green 2012-05-19 18:27:53 +08:00
parent 13aa9a455b
commit 7f2fa95d9a
2 changed files with 14 additions and 18 deletions

View File

@ -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 ) ;
}
}

View File

@ -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 )