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

Create a file system abstraction layer #172

Open
ubruhin opened this Issue Aug 1, 2017 · 0 comments

Comments

1 participant
@ubruhin
Member

ubruhin commented Aug 1, 2017

A LibrePCB project consist of many single files which need to be read and written all together. Adding library elements to a project is actually a recursive copy operation of a directory. And the auto-save & restore-after-crash feature creates a copy of every single file.

So LibrePCB heavily uses file system operations. But unfortunately this is not very well implemented until now, many classes are very complicated because they must implement for example the restore-after-crash feature by themselves. I'm pretty sure there are some cases where bad things can happen (e.g. destroying project files) because of bugs.

I think it would be best to introduce some kind of file system abstraction. It should be responsible for:

  • Allowing to open whole projects and library elements in read-only mode
  • Creating file locks on opened projects or library elements
  • Periodically creating backup files + allowing to restore the last backup after a crash
  • Writing all files of a project or library element (pseudo-)atomically to the disk
  • Allow to import/export LibrePCB projects from/to ZIP files
  • Load and save project library together with other files of the project (currently each library element handles loading/saving from/to files by itself, decoupled from the project)
  • Postpone all file operations until the project is saved the next time:
    • When adding a library element, its directory mustn't be copied to the project directory until the user saves the project. But the new library element must still be available! -> Save it to /tmp?
    • When adding a new sheet to the schematic, the new file mustn't be written to disk until it is saved
    • When removing a sheet from the schematic, the file mustn't be removed from disk until it is saved
  • Maybe only write files which have changed (improve performance, reduce write operations)
  • Watching for file modifications in the background (e.g. switching the git branch while a project is open)

The doxygen documentation describes (parts of) how this is implemented currently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment