Fix subdir/subsubdir/newfile bug

New files put in sub-subdirs of drive root were also trashed locally instead of begin uploaded to the server
pull/59/head
Vitaliy Filippov 2016-01-06 01:48:30 +03:00
parent 60acb75967
commit b6c0013052
1 changed files with 13 additions and 7 deletions

View File

@ -272,14 +272,20 @@ void Resource::FromLocal( Val& state )
if ( state.Has( "srv_time" ) )
m_mtime.Assign( state[ "srv_time" ].U64(), 0 ) ;
// follow parent recursively
if ( m_parent->m_state == local_new || m_parent->m_state == remote_deleted )
m_state = m_parent->m_state ;
else
// Upload file if it is changed and remove if not.
// State will be updated to sync/remote_changed in FromRemote()
m_state = is_changed ? local_new : remote_deleted;
if ( m_state == local_new )
{
// Upload file if it is changed and remove if not.
// State will be updated to sync/remote_changed in FromRemote()
m_state = is_changed ? local_new : remote_deleted;
// local_new means this file is changed in local.
// this means we can't delete any of its parents.
// make sure their state is also set to local_new.
Resource *p = m_parent;
while ( p && p->m_state == remote_deleted )
{
p->m_state = local_new;
p = p->m_parent;
}
}
}