mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2026-01-01 00:30:17 -05:00
parent
2a02242d44
commit
5cfbde0bb7
1 changed files with 14 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue