From 4c8d426f23b35c8865bc81f8fcd9d21e3869879c Mon Sep 17 00:00:00 2001 From: Janek Bevendorff Date: Tue, 27 Feb 2018 20:06:33 +0100 Subject: [PATCH] Use copy instead of rename for unsafe saving on Linux Resolves #1511 See https://bugreports.qt.io/browse/QTBUG-64008 --- src/core/Database.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/Database.cpp b/src/core/Database.cpp index 94b41cdf0..00cb76f48 100644 --- a/src/core/Database.cpp +++ b/src/core/Database.cpp @@ -537,11 +537,19 @@ QString Database::saveToFile(QString filePath, bool atomic, bool backup) // Delete the original db and move the temp file in place QFile::remove(filePath); +#ifdef Q_OS_LINUX + // workaround to make this workaround work, see: https://bugreports.qt.io/browse/QTBUG-64008 + if (tempFile.copy(filePath)) { + // successfully saved database file + return {}; + } +#else if (tempFile.rename(filePath)) { // successfully saved database file tempFile.setAutoRemove(false); return {}; } +#endif } error = tempFile.errorString(); }