mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-25 07:19:42 -05:00
Fix broken safe saves across file systems
* Fix #2888 * Qt has an undocumented rename implementation for QTemporaryFile that does not fallback to the copy implementation. Forcing the use of QFile::rename(...) allows for this fallback and protects against cross-device link errors.
This commit is contained in:
parent
835e1b8787
commit
ec82931573
@ -241,20 +241,16 @@ bool Database::save(const QString& filePath, QString* error, bool atomic, bool b
|
|||||||
|
|
||||||
// Delete the original db and move the temp file in place
|
// Delete the original db and move the temp file in place
|
||||||
QFile::remove(filePath);
|
QFile::remove(filePath);
|
||||||
#ifdef Q_OS_LINUX
|
|
||||||
// workaround to make this workaround work, see: https://bugreports.qt.io/browse/QTBUG-64008
|
// Note: call into the QFile rename instead of QTemporaryFile
|
||||||
if (tempFile.copy(filePath)) {
|
// due to an undocumented difference in how the function handles
|
||||||
// successfully saved database file
|
// errors. This prevents errors when saving across file systems.
|
||||||
return true;
|
if (tempFile.QFile::rename(filePath)) {
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (tempFile.rename(filePath)) {
|
|
||||||
// successfully saved database file
|
// successfully saved database file
|
||||||
tempFile.setAutoRemove(false);
|
tempFile.setAutoRemove(false);
|
||||||
setFilePath(filePath);
|
setFilePath(filePath);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (error) {
|
if (error) {
|
||||||
*error = tempFile.errorString();
|
*error = tempFile.errorString();
|
||||||
|
Loading…
Reference in New Issue
Block a user