summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/pwmdoc.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/pwmanager/pwmanager/pwmdoc.cpp b/pwmanager/pwmanager/pwmdoc.cpp
index 36b0df5..1f3c58b 100644
--- a/pwmanager/pwmanager/pwmdoc.cpp
+++ b/pwmanager/pwmanager/pwmdoc.cpp
@@ -391,97 +391,97 @@ PwMerror PwMDoc::saveDoc(char compress, const QString *file)
* document wasn't saved, yet.
*/
bool useChipcard = getDocStatFlag(DOC_STAT_USE_CHIPCARD);
QString pw(requestNewMpw(&useChipcard));
if (pw != "") {
currentPw = pw;
} else {
return e_noPw;
}
if (useChipcard) {
setDocStatFlag(DOC_STAT_USE_CHIPCARD);
} else {
unsetDocStatFlag(DOC_STAT_USE_CHIPCARD);
}
}
int _cryptAlgo = conf()->confGlobCryptAlgo();
int _hashAlgo = conf()->confGlobHashAlgo();
// sanity check for the selected algorithms
if (_cryptAlgo < PWM_CRYPT_BLOWFISH ||
_cryptAlgo > PWM_CRYPT_TWOFISH128) {
printWarn("Invalid Crypto-Algorithm selected! "
"Config-file seems to be corrupt. "
"Falling back to Blowfish.");
_cryptAlgo = PWM_CRYPT_BLOWFISH;
}
if (_hashAlgo < PWM_HASH_SHA1 ||
_hashAlgo > PWM_HASH_TIGER) {
printWarn("Invalid Hash-Algorithm selected! "
"Config-file seems to be corrupt. "
"Falling back to SHA1.");
_hashAlgo = PWM_HASH_SHA1;
}
char cryptAlgo = static_cast<char>(_cryptAlgo);
char hashAlgo = static_cast<char>(_hashAlgo);
if (conf()->confGlobMakeFileBackup()) {
if (!backupFile(filename))
return e_fileBackup;
}
int mLastBackupDate = 0;
KConfig configGlobal (locateLocal("config","pwmanagerbuprc"));
QFileInfo fileInfo ( filename );
mLastBackupDate = configGlobal.readNumEntry( "LastBackupDate-"+ fileInfo.fileName (), 0 );
KConfig config (locateLocal("config","microkdeglobalrc"));
config.setGroup( "BackupSettings" );
bool b_enabled = config.readBoolEntry( "BackupEnabled" );
- if ( b_enabled ) {
+ if ( b_enabled && QFile::exists(filename)) {
int num = config.readNumEntry( "BackupNumbers" );
int d_count = config.readNumEntry( "BackupDayCount" );
bool stdDir = config.readBoolEntry( "BackupUseDefaultDir" );
QString bupDir = config.readEntry( "BackupDatadir" );
QDate reference ( 2000,1,1 );
int daysTo = reference.daysTo ( QDate::currentDate() );
bool saveDate = false;
if ( daysTo - d_count >= mLastBackupDate ) {
qDebug("KA: Last backup was %d days ago ", daysTo - mLastBackupDate );
if ( stdDir )
bupDir = KGlobalSettings::backupDataDir();
int retval = KApplication::createBackup( filename, bupDir, num );
if ( retval == 0 ) {
qDebug("KO: Backup cancelled. Will try again tomorrow ");
// retval == 0 : backup skipped for today, try again tomorrow
mLastBackupDate = daysTo - d_count+1;
saveDate = true;
} else if ( retval == 1 ){
qDebug("KO: Backup created.");
// backup ok
mLastBackupDate = daysTo;
saveDate = true;
} else if ( retval == 2 ){
qDebug("KO: Backup globally cancelled.");
// backup globally cancelled
b_enabled = false;
}
if ( !b_enabled ) {
config.writeEntry( "mBackupEnabled", false );
}
if ( saveDate ) {
configGlobal.writeEntry( "LastBackupDate-"+ fileInfo.fileName (), mLastBackupDate );
}
}
}
if (QFile::exists(filename)) {
/* Move the existing file to some tmp file.
* When saving file succeeds, delete tmp file. Otherwise
* move tmp file back. See below.
*/
Randomizer *rnd = Randomizer::obj();
char rnd_buf[5];
sprintf(rnd_buf, "%X%X%X%X", rnd->genRndChar() & 0xFF, rnd->genRndChar() & 0xFF,
rnd->genRndChar() & 0xFF, rnd->genRndChar() & 0xFF);
tmpFileMoved = filename + "." + rnd_buf + ".mv";
if (!copyFile(filename, tmpFileMoved))
return e_openFile;
if (!QFile::remove(filename)) {