Fix local index updating for items already in sync

pull/59/head
Vitaliy Filippov 2016-01-06 01:37:52 +03:00
parent c76cdecad2
commit 60acb75967
2 changed files with 9 additions and 5 deletions

View File

@ -574,14 +574,14 @@ void Resource::SyncSelf( Syncer* syncer, ResourceTree *res_tree, const Val& opti
case sync :
Log( "sync %1% already in sync", path, log::verbose ) ;
if ( !IsRoot() )
SetIndex( false ) ;
break ;
// shouldn't go here
case unknown :
assert( false ) ;
break ;
default :
assert( false ) ;
break ;
}
@ -635,15 +635,17 @@ void Resource::DeleteIndex()
void Resource::SetIndex( bool re_stat )
{
assert( m_parent->m_json != NULL );
assert( m_parent && m_parent->m_json != NULL );
if ( !m_json )
m_json = &((*m_parent->m_json)["tree"]).Item( Name() );
bool is_dir;
if ( re_stat )
os::Stat( Path(), &m_ctime, NULL, &is_dir );
else
is_dir = IsFolder();
m_json->Set( "ctime", Val( m_ctime.Sec() ) );
if ( !is_dir )
{
m_json->Set( "ctime", Val( m_ctime.Sec() ) );
m_json->Set( "md5", Val( m_md5 ) );
m_json->Del( "tree" );
}

View File

@ -116,6 +116,8 @@ const Val& Val::operator[]( std::size_t index ) const
std::string Val::Str() const
{
if ( Type() == int_type )
return boost::to_string( As<long long>() );
return As<std::string>() ;
}