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
Vladimir Stackov 2015-08-20 12:01:09 +03:00
parent ff113999a2
commit 4bd4fa8fa1
4 changed files with 37 additions and 3 deletions

View File

@ -133,6 +133,15 @@ void Config::prefillKeywords()
"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 }
};
@ -475,6 +484,15 @@ bool Config::parseOrValidate( const string & option, const OptionType type,
/* NOTREACHED */
break;
case oRuntime_pathsRespectTmp:
runtime.pathsRespectTmp = true;
dPrintf( "runtime[pathsRespectTmp] = true\n" );
return true;
/* NOTREACHED */
break;
case oBadOption:
default:
return false;

View File

@ -30,12 +30,14 @@ public:
size_t cacheSize;
bitset< BackupExchanger::Flags > exchange;
bool gcRepack;
bool pathsRespectTmp;
// Default runtime config
RuntimeConfig():
threads( getNumberOfCpus() ),
cacheSize( 40 * 1024 * 1024 ), // 40 MB
gcRepack ( false )
gcRepack ( false ),
pathsRespectTmp( false )
{
}
};
@ -61,6 +63,7 @@ public:
oRuntime_cacheSize,
oRuntime_exchange,
oRuntime_gcRepack,
oRuntime_pathsRespectTmp,
oDeprecated, oUnsupported
} OpCodes;

View File

@ -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()
{
if ( config.runtime.pathsRespectTmp )
{
char * tmpdir;
if ( ( ( tmpdir = getenv( "TMPDIR" ) ) != NULL && *tmpdir != '\0' ) )
return string( tmpdir );
}
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,
Config & configIn ):
Paths( storageDir ), storageInfo( loadStorageInfo() ),
Paths( storageDir, configIn ), storageInfo( loadStorageInfo() ),
encryptionkey( password, storageInfo.has_encryption_key() ?
&storageInfo.encryption_key() : 0 ),
extendedStorageInfo( loadExtendedStorageInfo( encryptionkey ) ),
@ -105,7 +116,7 @@ ZBackupBase::ZBackupBase( string const & storageDir, string const & password,
ZBackupBase::ZBackupBase( string const & storageDir, string const & password,
Config & configIn, bool prohibitChunkIndexLoading ):
Paths( storageDir ), storageInfo( loadStorageInfo() ),
Paths( storageDir, configIn ), storageInfo( loadStorageInfo() ),
encryptionkey( password, storageInfo.has_encryption_key() ?
&storageInfo.encryption_key() : 0 ),
extendedStorageInfo( loadExtendedStorageInfo( encryptionkey ) ),

View File

@ -13,9 +13,11 @@
struct Paths
{
Config config;
std::string storageDir;
Paths( std::string const & storageDir );
Paths( std::string const & storageDir, Config const & );
std::string getTmpPath();
std::string getRestorePath();