Summary: | Overwriting a gpg-encrypted file results in a zero byte file | ||
---|---|---|---|
Product: | [Applications] kmymoney | Reporter: | Ralf Habacker <ralf.habacker> |
Component: | file | Assignee: | KMyMoney Devel Mailing List <kmymoney-devel> |
Status: | RESOLVED FIXED | ||
Severity: | major | ||
Priority: | NOR | ||
Version: | 5.1.1 | ||
Target Milestone: | --- | ||
Platform: | Microsoft Windows | ||
OS: | Microsoft Windows | ||
Latest Commit: | https://invent.kde.org/office/kmymoney/commit/646c4cb810a960699b1b659d72bef248992f4e40 | Version Fixed In: | 5.1.2 |
Sentry Crash Report: | |||
Bug Depends on: | |||
Bug Blocks: | 426400 |
Description
Ralf Habacker
2021-05-05 17:27:44 UTC
An investigation shows that there is a problem when QTemporaryFile and QSaveFile are used together on Windows. For the case of creating a local gpg-encrypted file, only one KSaveFile instance inside KMyMoneyView::saveToLocalFile() https://github.com/KDE/kmymoney/blob/07d368edf5098cb06774a1cecc41551ce3ad43c5/kmymoney/views/kmymoneyview.cpp#L1151 was used in the 4.8 branch, which also works as expected for the case that the file to be created already existed before. In the 5.1 branch the procedure was changed so that in the mentioned function first a QTemporaryFile instance is created and if the resulting file already exists, the file name created in this way is passed to the KGPGFile instance, which internally uses a QSaveFile instance, which in turn creates a temporary file. Something goes wrong with this multiple renaming or copying. If you omit the superfluous use of the QTemporaryFile instance in the case mentioned, it works as expected. Git commit 39785a3d80c56dc6e53f301d76c41bcc8ca048c6 by Thomas Baumgart. Committed on 12/05/2021 at 06:33. Pushed by tbaumgart into branch '5.1'. Solve problems with usage of QTemporaryFile on MS-Windows A call to QTemporaryFile::close() may not close the file but only rewind the file pointer to the beginning allwing faster re-open. This causes problems on MS-Windows filesystems, as one cannot e.g. rename the temporary file in this case because it is still kept open from the perspective of the filesystem. Only destroying the object really closes the file on the filesystem. This change makes sure, that the QTemporaryFile object only lives as long as it is needed and closed immediately after by destroying the object. FIXED-IN: 5.1.2 M +18 -10 kmymoney/plugins/xml/xmlstorage.cpp https://invent.kde.org/office/kmymoney/commit/39785a3d80c56dc6e53f301d76c41bcc8ca048c6 Git commit 646c4cb810a960699b1b659d72bef248992f4e40 by Thomas Baumgart. Committed on 12/05/2021 at 06:54. Pushed by tbaumgart into branch 'master'. Solve problems with usage of QTemporaryFile on MS-Windows A call to QTemporaryFile::close() may not close the file but only rewind the file pointer to the beginning allwing faster re-open. This causes problems on MS-Windows filesystems, as one cannot e.g. rename the temporary file in this case because it is still kept open from the perspective of the filesystem. Only destroying the object really closes the file on the filesystem. This change makes sure, that the QTemporaryFile object only lives as long as it is needed and closed immediately after by destroying the object. FIXED-IN: 5.1.2 (cherry picked from commit 39785a3d80c56dc6e53f301d76c41bcc8ca048c6) M +18 -10 kmymoney/plugins/xml/xmlstorage.cpp https://invent.kde.org/office/kmymoney/commit/646c4cb810a960699b1b659d72bef248992f4e40 |