Reduce number of syscalls while scanning local files

pull/40/head
Visa Putkinen 2013-11-24 14:34:03 +02:00
parent c15bfbe8bc
commit 8b434dad14
2 changed files with 6 additions and 5 deletions

View File

@ -252,7 +252,7 @@ void Resource::FromRemoteFile( const Entry& remote, const DateTime& last_sync )
void Resource::FromLocal( const DateTime& last_sync )
{
fs::path path = Path() ;
assert( fs::exists( path ) ) ;
//assert( fs::exists( path ) ) ;
// root folder is always in sync
if ( !IsRoot() )
@ -270,8 +270,8 @@ void Resource::FromLocal( const DateTime& last_sync )
m_state = ( m_mtime > last_sync ? local_new : remote_deleted ) ;
m_name = path.filename().string() ;
m_kind = fs::is_directory(path) ? "folder" : "file" ;
m_md5 = fs::is_directory(path) ? "" : crypt::MD5::Get( path ) ;
//m_kind = fs::is_directory(path) ? "folder" : "file" ;
m_md5 = IsFolder() ? "" : crypt::MD5::Get( path ) ;
}
assert( m_state != unknown ) ;

View File

@ -84,19 +84,20 @@ void State::FromLocal( const fs::path& p, Resource* folder )
else
{
bool is_dir = fs::is_directory(i->path());
// if the Resource object of the child already exists, it should
// have been so no need to do anything here
Resource *c = folder->FindChild( fname ) ;
if ( c == 0 )
{
c = new Resource( fname, fs::is_directory(i->path()) ? "folder" : "file" ) ;
c = new Resource( fname, is_dir ? "folder" : "file" ) ;
folder->AddChild( c ) ;
m_res.Insert( c ) ;
}
c->FromLocal( m_last_sync ) ;
if ( fs::is_directory( i->path() ) )
if ( is_dir )
FromLocal( *i, c ) ;
}
}