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

Single file format #1558

Closed
wants to merge 22 commits into from
Closed

Single file format #1558

wants to merge 22 commits into from

Conversation

vkbo
Copy link
Owner

@vkbo vkbo commented Oct 29, 2023

Summary:

This PR adds an option to save projects as a single file. It uses the NWStorage wrapper class that was created for the 2.0 release which abstracts all interactions with the file system. It was built to handle various ways of storing the project, including as a single file format.

The implementation here keeps the project in a zip file with the .nwproj file extension. The zip file's comment field contains a string which meta data, but the data isn't strictly required. However, it contains a type field that lets novelWriter know whether the archive is a project or a backup. In case of it being a backup, it is opened as read only by default.

When a single file project is opened, it is extracted into a project folder in novelWriter's data area. The folder name is the SHA1 hash of the file path, so it should be unique for each project. This allows recovery in case of a crash, as it can then check if the folder already exists. The folder is normally deleted when a project is successfully closed.

Side effects:

  • Backups are now also saved as .nwproj files rather than .zip files. They can then be opened as read only projects.
  • Inside the archives, the main project XML file is named nwProject.xml rather than nwProject.nwx. The .nwx extensions is registered as a mime type for folder projects, and keeping it inside the archive can cause confusion when opening manually.

Related Issue(s):

Closes #977

Reviewer's Checklist:

  • The header of all files contain a reference to the repository license
  • The overall test coverage is increased or remains the same as before
  • All tests are passing
  • All flake8 checks are passing and the style guide is followed
  • Documentation (as docstrings) is complete and understandable
  • Only files that have been actively changed are committed

@vkbo vkbo added this to the Release 2.2 Beta 1 milestone Oct 29, 2023
@vkbo
Copy link
Owner Author

vkbo commented Nov 18, 2023

Closing this in favour of a new branch

@vkbo vkbo closed this Nov 18, 2023
@vkbo vkbo deleted the single_file branch November 18, 2023 16:52
@vkbo vkbo mentioned this pull request Dec 1, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant