check whether the current file is empty before creating backup
This commit is contained in:
parent
3128d31536
commit
76b5abb5ba
|
@ -420,11 +420,16 @@ void PasswordFile::doBackup()
|
||||||
if(!isOpen()) {
|
if(!isOpen()) {
|
||||||
open();
|
open();
|
||||||
}
|
}
|
||||||
fstream backupFile(m_path + ".backup", ios::out | ios::binary);
|
m_file.seekg(0, ios_base::end);
|
||||||
backupFile.exceptions(ios_base::failbit | ios_base::badbit);
|
if(m_file.tellg()) {
|
||||||
m_file.seekg(0);
|
m_file.seekg(0);
|
||||||
backupFile << m_file.rdbuf();
|
fstream backupFile(m_path + ".backup", ios::out | ios::trunc | ios::binary);
|
||||||
backupFile.close();
|
backupFile.exceptions(ios_base::failbit | ios_base::badbit);
|
||||||
|
backupFile << m_file.rdbuf();
|
||||||
|
backupFile.close();
|
||||||
|
} else {
|
||||||
|
// the current file is empty anyways
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
Loading…
Reference in New Issue