Use copy instead of rename for unsafe saving on Linux

Resolves #1511
See https://bugreports.qt.io/browse/QTBUG-64008
This commit is contained in:
Janek Bevendorff 2018-02-27 20:06:33 +01:00
parent 395afe59eb
commit 4c8d426f23

View File

@ -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();
}