mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
parent
6acd0b25ae
commit
33bf6eb892
@ -283,6 +283,11 @@ bool Database::saveAs(const QString& filePath, QString* error, bool atomic, bool
|
||||
|
||||
bool Database::performSave(const QString& filePath, QString* error, bool atomic, bool backup)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||
QFileInfo info(filePath);
|
||||
auto createTime = info.exists() ? info.birthTime() : QDateTime::currentDateTime();
|
||||
#endif
|
||||
|
||||
if (atomic) {
|
||||
QSaveFile saveFile(filePath);
|
||||
if (saveFile.open(QIODevice::WriteOnly)) {
|
||||
@ -295,6 +300,11 @@ bool Database::performSave(const QString& filePath, QString* error, bool atomic,
|
||||
backupDatabase(filePath);
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||
// Retain orginal creation time
|
||||
saveFile.setFileTime(createTime, QFile::FileBirthTime);
|
||||
#endif
|
||||
|
||||
if (saveFile.commit()) {
|
||||
// successfully saved database file
|
||||
return true;
|
||||
@ -329,6 +339,10 @@ bool Database::performSave(const QString& filePath, QString* error, bool atomic,
|
||||
// successfully saved the database
|
||||
tempFile.setAutoRemove(false);
|
||||
QFile::setPermissions(filePath, perms);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||
// Retain orginal creation time
|
||||
tempFile.setFileTime(createTime, QFile::FileBirthTime);
|
||||
#endif
|
||||
return true;
|
||||
} else if (!backup || !restoreDatabase(filePath)) {
|
||||
// Failed to copy new database in place, and
|
||||
|
Loading…
Reference in New Issue
Block a user