mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-18 03:54:14 +02:00
Sync the folder after saving, and save from the command line through a temporary file
QSaveFile writes a new file, forces it to disk and renames it over the old one, but does not force the folder to disk. On ext4 or XFS a power cut soon after a save can then lose the rename: the previous file comes back, or none. QET::syncFolderOf() now syncs the folder after every project, symbol and title block save (QET::writeXmlText()) and every .qetz save (QetZip::write()). Nothing to do on Windows. --resave and --set-titleblock wrote a .qet straight over the output file (QFile, truncate, write): a run stopped part-way left half a project. They now write through QET::writeXmlText() like the GUI's save. On Windows their .qet now has LF line ends, as the GUI writes. Checked with strace on --resave: fdatasync of the new file, linkat into place, fsync of the folder. The .qet written is byte-identical to before. ctest 106/106. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "qetapp.h"
|
||||
#include "qeticons.h"
|
||||
#include "shortcutmanager.h"
|
||||
#include "utils/syncfolder.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
@@ -809,6 +810,7 @@ bool QET::writeXmlText(const QString &text, const QString &filepath, QString *er
|
||||
|
||||
return false;
|
||||
}
|
||||
syncFolderOf(filepath);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user