diff --git a/libgrive/src/base/Drive.cc b/libgrive/src/base/Drive.cc index a8efb8a..7aa282a 100644 --- a/libgrive/src/base/Drive.cc +++ b/libgrive/src/base/Drive.cc @@ -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( ) diff --git a/libgrive/src/base/Resource.cc b/libgrive/src/base/Resource.cc index e206ebc..32c7752 100644 --- a/libgrive/src/base/Resource.cc +++ b/libgrive/src/base/Resource.cc @@ -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() ) ;