Closed Witiko closed 3 years ago
Excuse the late reply, I just now found time to look into the PR. The changes should vastly improve the workflow when using a savedir, thank you.
@maxnth Thanks. However, as I mentioned, using savedir for both reading and writing will lead to race conditions. The race where two users load the same XML file, perform different changes, and then overwrite each other's changes is difficult to overcome, but we should at least lock the file when writing, so that you can never read or write a partially written XML file and corrupt the data.
This change makes it possible not only to save updated XML files to a savedir, but also to load them back from the savedir when the page has been refreshed. This turns the savedir into an overlay read-write layer for the bookpath, which may be the prefered modus operandi if we'd like to keep the bookpath read-only, but also allow the users to change the annotations.
With more than one user, this change can produce race conditions, where a user may load an incomplete annotation from the savedir. Using advisory locking should solve this problem: