mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-06 13:34:16 -04:00
parent
6acd0b25ae
commit
33bf6eb892
1 changed files with 14 additions and 0 deletions
|
@ -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)
|
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) {
|
if (atomic) {
|
||||||
QSaveFile saveFile(filePath);
|
QSaveFile saveFile(filePath);
|
||||||
if (saveFile.open(QIODevice::WriteOnly)) {
|
if (saveFile.open(QIODevice::WriteOnly)) {
|
||||||
|
@ -295,6 +300,11 @@ bool Database::performSave(const QString& filePath, QString* error, bool atomic,
|
||||||
backupDatabase(filePath);
|
backupDatabase(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||||
|
// Retain orginal creation time
|
||||||
|
saveFile.setFileTime(createTime, QFile::FileBirthTime);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (saveFile.commit()) {
|
if (saveFile.commit()) {
|
||||||
// successfully saved database file
|
// successfully saved database file
|
||||||
return true;
|
return true;
|
||||||
|
@ -329,6 +339,10 @@ bool Database::performSave(const QString& filePath, QString* error, bool atomic,
|
||||||
// successfully saved the database
|
// successfully saved the database
|
||||||
tempFile.setAutoRemove(false);
|
tempFile.setAutoRemove(false);
|
||||||
QFile::setPermissions(filePath, perms);
|
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;
|
return true;
|
||||||
} else if (!backup || !restoreDatabase(filePath)) {
|
} else if (!backup || !restoreDatabase(filePath)) {
|
||||||
// Failed to copy new database in place, and
|
// Failed to copy new database in place, and
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue