mirror of https://github.com/vitalif/zbackup
Resolves #76
Now it was possible to specify path to tmp directory using TMPDIR environment variable, i.e.: cat /111 | TMPDIR=/tmp/ zbackup backup -O paths.respect_tmp <..>master
parent
ff113999a2
commit
4bd4fa8fa1
18
config.cc
18
config.cc
|
@ -133,6 +133,15 @@ void Config::prefillKeywords()
|
||||||
"Not default, you should specify it explicitly."
|
"Not default, you should specify it explicitly."
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"paths.respect_tmp",
|
||||||
|
Config::oRuntime_pathsRespectTmp,
|
||||||
|
Config::Runtime,
|
||||||
|
"ZBackup will use TMPDIR environment variable\n"
|
||||||
|
"for temporary files if set.\n"
|
||||||
|
"Not default, you should specify it explicitly."
|
||||||
|
},
|
||||||
|
|
||||||
{ "", Config::oBadOption, Config::None }
|
{ "", Config::oBadOption, Config::None }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -475,6 +484,15 @@ bool Config::parseOrValidate( const string & option, const OptionType type,
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case oRuntime_pathsRespectTmp:
|
||||||
|
runtime.pathsRespectTmp = true;
|
||||||
|
|
||||||
|
dPrintf( "runtime[pathsRespectTmp] = true\n" );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
/* NOTREACHED */
|
||||||
|
break;
|
||||||
|
|
||||||
case oBadOption:
|
case oBadOption:
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -30,12 +30,14 @@ public:
|
||||||
size_t cacheSize;
|
size_t cacheSize;
|
||||||
bitset< BackupExchanger::Flags > exchange;
|
bitset< BackupExchanger::Flags > exchange;
|
||||||
bool gcRepack;
|
bool gcRepack;
|
||||||
|
bool pathsRespectTmp;
|
||||||
|
|
||||||
// Default runtime config
|
// Default runtime config
|
||||||
RuntimeConfig():
|
RuntimeConfig():
|
||||||
threads( getNumberOfCpus() ),
|
threads( getNumberOfCpus() ),
|
||||||
cacheSize( 40 * 1024 * 1024 ), // 40 MB
|
cacheSize( 40 * 1024 * 1024 ), // 40 MB
|
||||||
gcRepack ( false )
|
gcRepack ( false ),
|
||||||
|
pathsRespectTmp( false )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -61,6 +63,7 @@ public:
|
||||||
oRuntime_cacheSize,
|
oRuntime_cacheSize,
|
||||||
oRuntime_exchange,
|
oRuntime_exchange,
|
||||||
oRuntime_gcRepack,
|
oRuntime_gcRepack,
|
||||||
|
oRuntime_pathsRespectTmp,
|
||||||
|
|
||||||
oDeprecated, oUnsupported
|
oDeprecated, oUnsupported
|
||||||
} OpCodes;
|
} OpCodes;
|
||||||
|
|
|
@ -29,8 +29,19 @@ Paths::Paths( string const & storageDir ): storageDir( storageDir )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Paths::Paths( string const & storageDir, Config const & config ):
|
||||||
|
storageDir( storageDir ), config( config )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
string Paths::getTmpPath()
|
string Paths::getTmpPath()
|
||||||
{
|
{
|
||||||
|
if ( config.runtime.pathsRespectTmp )
|
||||||
|
{
|
||||||
|
char * tmpdir;
|
||||||
|
if ( ( ( tmpdir = getenv( "TMPDIR" ) ) != NULL && *tmpdir != '\0' ) )
|
||||||
|
return string( tmpdir );
|
||||||
|
}
|
||||||
return string( Dir::addPath( storageDir, "tmp" ) );
|
return string( Dir::addPath( storageDir, "tmp" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +86,7 @@ ZBackupBase::ZBackupBase( string const & storageDir, string const & password ):
|
||||||
|
|
||||||
ZBackupBase::ZBackupBase( string const & storageDir, string const & password,
|
ZBackupBase::ZBackupBase( string const & storageDir, string const & password,
|
||||||
Config & configIn ):
|
Config & configIn ):
|
||||||
Paths( storageDir ), storageInfo( loadStorageInfo() ),
|
Paths( storageDir, configIn ), storageInfo( loadStorageInfo() ),
|
||||||
encryptionkey( password, storageInfo.has_encryption_key() ?
|
encryptionkey( password, storageInfo.has_encryption_key() ?
|
||||||
&storageInfo.encryption_key() : 0 ),
|
&storageInfo.encryption_key() : 0 ),
|
||||||
extendedStorageInfo( loadExtendedStorageInfo( encryptionkey ) ),
|
extendedStorageInfo( loadExtendedStorageInfo( encryptionkey ) ),
|
||||||
|
@ -105,7 +116,7 @@ ZBackupBase::ZBackupBase( string const & storageDir, string const & password,
|
||||||
|
|
||||||
ZBackupBase::ZBackupBase( string const & storageDir, string const & password,
|
ZBackupBase::ZBackupBase( string const & storageDir, string const & password,
|
||||||
Config & configIn, bool prohibitChunkIndexLoading ):
|
Config & configIn, bool prohibitChunkIndexLoading ):
|
||||||
Paths( storageDir ), storageInfo( loadStorageInfo() ),
|
Paths( storageDir, configIn ), storageInfo( loadStorageInfo() ),
|
||||||
encryptionkey( password, storageInfo.has_encryption_key() ?
|
encryptionkey( password, storageInfo.has_encryption_key() ?
|
||||||
&storageInfo.encryption_key() : 0 ),
|
&storageInfo.encryption_key() : 0 ),
|
||||||
extendedStorageInfo( loadExtendedStorageInfo( encryptionkey ) ),
|
extendedStorageInfo( loadExtendedStorageInfo( encryptionkey ) ),
|
||||||
|
|
|
@ -13,9 +13,11 @@
|
||||||
|
|
||||||
struct Paths
|
struct Paths
|
||||||
{
|
{
|
||||||
|
Config config;
|
||||||
std::string storageDir;
|
std::string storageDir;
|
||||||
|
|
||||||
Paths( std::string const & storageDir );
|
Paths( std::string const & storageDir );
|
||||||
|
Paths( std::string const & storageDir, Config const & );
|
||||||
|
|
||||||
std::string getTmpPath();
|
std::string getTmpPath();
|
||||||
std::string getRestorePath();
|
std::string getRestorePath();
|
||||||
|
|
Loading…
Reference in New Issue