Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI: Fail-safe file save #228

Closed
rakhimov opened this issue Oct 19, 2017 · 0 comments
Closed

GUI: Fail-safe file save #228

rakhimov opened this issue Oct 19, 2017 · 0 comments

Comments

@rakhimov
Copy link
Owner

Upon file save operations,
should the program, system, or IO fail for any reason,
the Model file should never be left in a partial state or be corrupted.

Note that this does not apply to "exported" files,
such as graphics (SVG), print-save (PDF), or report (MEF XML).

Qt provides QSaveFile for this purpose; however, it implies the use of Qt File API -- not C API.
The core code works with C API
and currently doesn't report C stdio write-function failures.

Moreover, the IO operations are blocking, so there should be some status line messages.

@rakhimov rakhimov added this to the v0.16.0 milestone Oct 19, 2017
rakhimov added a commit that referenced this issue Oct 20, 2017
The IO errors should not be ignored
when file integrity is of concern.
Serialization and reporting are now IO write-failure aware.

For efficiency reasons, the stdio FILE error code is tested
only at the end of XML Streaming in the RAII class destructor.
The IO exceptions are thrown conservatively
only if there are no other exceptions on flight.
More detailed stack unwinding w/ unhandled exception
can be detected in future with C++17 'uncaught_exceptions' function.

Issue #228
rakhimov added a commit that referenced this issue Oct 20, 2017
This is not the cleanest solution.
The temporary file is created in the same file system directory,
and then rename/move operation is performed.
This approach assumes that user has permission
to create files in the directory.
Moreover, it may mess up the file permission of the original file.

The rename operation will not succeed cleanly
if the original file is a symlink.
In this case, the symlink is replaced with a new file.

Issue #228
rakhimov added a commit that referenced this issue Oct 20, 2017
Since model serialization is expected to be fast and fail-safe,
there should be no risk or inconvenience with auto-save.

Issue #228
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant