Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan White <support@dmapps.us>2021-06-01 05:22:50 +0300
committerJonathan White <support@dmapps.us>2021-06-02 04:50:12 +0300
commit5cfbde0bb73e66385b0f714ed0e9f0b7b69ba830 (patch)
tree0d0840bd1096a6d19e5d69770110e0ff96c04bf7
parent2a02242d441df029f0e881d3589d8abfc55b102e (diff)
Retain file creation time when saving database (#6576)
* Fix #6028
-rw-r--r--src/core/Database.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/core/Database.cpp b/src/core/Database.cpp
index be9adfa45..f13c00796 100644
--- a/src/core/Database.cpp
+++ b/src/core/Database.cpp
@@ -272,6 +272,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)) {
@@ -284,6 +289,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;
@@ -318,6 +328,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