mirror of https://github.com/vitalif/zbackup
parent
3bde1c404e
commit
4298a0f111
|
@ -10,6 +10,7 @@
|
|||
#include "chunk_index.hh"
|
||||
#include "backup_restorer.hh"
|
||||
#include "backup_file.hh"
|
||||
#include "backup_exchanger.hh"
|
||||
|
||||
#include "debug.hh"
|
||||
|
||||
|
@ -138,9 +139,6 @@ void ZCollector::gc()
|
|||
chunkReindex, getBundlesPath(), getIndexPath(), config.runtime.threads );
|
||||
|
||||
string fileName;
|
||||
string backupsPath = getBackupsPath();
|
||||
|
||||
Dir::Listing lst( backupsPath );
|
||||
|
||||
Dir::Entry entry;
|
||||
|
||||
|
@ -152,13 +150,18 @@ void ZCollector::gc()
|
|||
|
||||
verbosePrintf( "Checking used chunks...\n" );
|
||||
|
||||
while( lst.getNext( entry ) )
|
||||
verbosePrintf( "Searching for backups...\n" );
|
||||
vector< string > backups = BackupExchanger::findOrRebuild( getBackupsPath() );
|
||||
|
||||
for ( std::vector< string >::iterator it = backups.begin(); it != backups.end(); ++it )
|
||||
{
|
||||
verbosePrintf( "Checking backup %s...\n", entry.getFileName().c_str() );
|
||||
string backup( Dir::addPath( getBackupsPath(), *it ) );
|
||||
|
||||
verbosePrintf( "Checking backup %s...\n", backup.c_str() );
|
||||
|
||||
BackupInfo backupInfo;
|
||||
|
||||
BackupFile::load( Dir::addPath( backupsPath, entry.getFileName() ), encryptionkey, backupInfo );
|
||||
BackupFile::load( backup, encryptionkey, backupInfo );
|
||||
|
||||
string backupData;
|
||||
|
||||
|
@ -180,10 +183,11 @@ void ZCollector::gc()
|
|||
while( bundleLst.getNext( entry ) )
|
||||
{
|
||||
const string dirPath = Dir::addPath( bundlesPath, entry.getFileName());
|
||||
if (entry.isDir() && Dir::isDirEmpty(dirPath)) {
|
||||
Dir::remove(dirPath);
|
||||
if ( entry.isDir() && Dir::isDirEmpty( dirPath ) )
|
||||
{
|
||||
Dir::remove( dirPath );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
verbosePrintf( "Garbage collection complete\n" );
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace BackupExchanger {
|
||||
|
||||
vector< string > recreateDirectories( string const & src, string const & dst, string const & relativePath )
|
||||
vector< string > findOrRebuild( string const & src, string const & dst, string const & relativePath )
|
||||
{
|
||||
vector< string > files;
|
||||
|
||||
|
@ -26,15 +26,15 @@ vector< string > recreateDirectories( string const & src, string const & dst, st
|
|||
if ( entry.isDir() )
|
||||
{
|
||||
verbosePrintf( "Found directory %s...\n", currentRelativePath.c_str() );
|
||||
string srcFullPath ( Dir::addPath( src, currentRelativePath ) );
|
||||
string dstFullPath ( Dir::addPath( dst, currentRelativePath ) );
|
||||
if ( !Dir::exists( dstFullPath.c_str() ) )
|
||||
string srcFullPath( Dir::addPath( src, currentRelativePath ) );
|
||||
string dstFullPath( Dir::addPath( dst, currentRelativePath ) );
|
||||
if ( !dst.empty() && !Dir::exists( dstFullPath.c_str() ) )
|
||||
{
|
||||
verbosePrintf( "Directory %s not found in destination, creating...\n",
|
||||
currentRelativePath.c_str() );
|
||||
Dir::create( dstFullPath.c_str() );
|
||||
}
|
||||
vector< string > subFiles ( recreateDirectories( src, dst, currentRelativePath ) );
|
||||
vector< string > subFiles( findOrRebuild( src, dst, currentRelativePath ) );
|
||||
files.insert( files.end(), subFiles.begin(), subFiles.end() );
|
||||
}
|
||||
else
|
||||
|
|
|
@ -22,7 +22,9 @@ enum {
|
|||
};
|
||||
|
||||
/// Recreate source directory structure in destination
|
||||
vector< string > recreateDirectories( string const & src, string const & dst, string const & relativePath = std::string() );
|
||||
vector< string > findOrRebuild( string const & src,
|
||||
string const & dst = std::string(),
|
||||
string const & relativePath = std::string() );
|
||||
typedef pair< sptr< TemporaryFile >, string > PendingExchangeRename;
|
||||
}
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ Config::~Config()
|
|||
}
|
||||
|
||||
Config::Config():
|
||||
want_cleanup( true )
|
||||
want_cleanup( false )
|
||||
{
|
||||
ConfigInfo * configInfo = new ConfigInfo;
|
||||
storable = configInfo;
|
||||
|
|
|
@ -178,7 +178,7 @@ void ZExchange::exchange()
|
|||
{
|
||||
verbosePrintf( "Searching for bundles...\n" );
|
||||
|
||||
vector< string > bundles = BackupExchanger::recreateDirectories(
|
||||
vector< string > bundles = BackupExchanger::findOrRebuild(
|
||||
srcZBackupBase.getBundlesPath(), dstZBackupBase.getBundlesPath() );
|
||||
|
||||
for ( std::vector< string >::iterator it = bundles.begin(); it != bundles.end(); ++it )
|
||||
|
@ -214,7 +214,7 @@ void ZExchange::exchange()
|
|||
if ( config.runtime.exchange.test( BackupExchanger::index ) )
|
||||
{
|
||||
verbosePrintf( "Searching for indicies...\n" );
|
||||
vector< string > indicies = BackupExchanger::recreateDirectories(
|
||||
vector< string > indicies = BackupExchanger::findOrRebuild(
|
||||
srcZBackupBase.getIndexPath(), dstZBackupBase.getIndexPath() );
|
||||
|
||||
for ( std::vector< string >::iterator it = indicies.begin(); it != indicies.end(); ++it )
|
||||
|
@ -259,7 +259,7 @@ void ZExchange::exchange()
|
|||
BackupInfo backupInfo;
|
||||
|
||||
verbosePrintf( "Searching for backups...\n" );
|
||||
vector< string > backups = BackupExchanger::recreateDirectories(
|
||||
vector< string > backups = BackupExchanger::findOrRebuild(
|
||||
srcZBackupBase.getBackupsPath(), dstZBackupBase.getBackupsPath() );
|
||||
|
||||
for ( std::vector< string >::iterator it = backups.begin(); it != backups.end(); ++it )
|
||||
|
|
Loading…
Reference in New Issue