mirror of https://github.com/vitalif/grive2
Fix .trash and .grive_state in drive location when used with -p option
Previously .trash and .grive_state were incorrectly placed in the current working directory instead of synced root directory (-p).pull/40/head
parent
f288c559c6
commit
d9300c953e
|
@ -85,7 +85,7 @@ void Drive::FromChange( const Entry& entry )
|
|||
|
||||
void Drive::SaveState()
|
||||
{
|
||||
m_state.Write( state_file ) ;
|
||||
m_state.Write( m_root / state_file ) ;
|
||||
}
|
||||
|
||||
void Drive::SyncFolders( )
|
||||
|
|
|
@ -461,13 +461,20 @@ void Resource::DeleteLocal()
|
|||
static const boost::format trash_file( "%1%-%2%" ) ;
|
||||
|
||||
assert( m_parent != 0 ) ;
|
||||
fs::path parent = m_parent->Path() ;
|
||||
fs::path dest = ".trash" / parent / Name() ;
|
||||
|
||||
Resource* p = m_parent;
|
||||
fs::path destdir;
|
||||
while ( !p->IsRoot() )
|
||||
{
|
||||
destdir = p->Name() / destdir;
|
||||
p = p->Parent();
|
||||
}
|
||||
destdir = p->Path() / ".trash" / destdir;
|
||||
|
||||
fs::path dest = destdir / Name();
|
||||
std::size_t idx = 1 ;
|
||||
while ( fs::exists( dest ) && idx != 0 )
|
||||
dest = ".trash" / parent / (boost::format(trash_file) % Name() % idx++).str() ;
|
||||
|
||||
dest = destdir / (boost::format(trash_file) % Name() % idx++).str() ;
|
||||
|
||||
// wrap around! just remove the file
|
||||
if ( idx == 0 )
|
||||
fs::remove_all( Path() ) ;
|
||||
|
|
Loading…
Reference in New Issue