Open anaestheticsapp opened 3 years ago
Is there a way to work around this issue?
for now maybe try to compare the lastModifiedDate from getFile() before saving?
I'm not sure this is a good idea since locking files is not always possible. For example, a network drive or FUSE drive might not provide the ability to lock files.
It would be nice to have an event or some way of checking that a file was edited via an external editor... rather than having to try to read the file and getting error and hoping a retry will work... like #72
My hope is that we'll be able to expose the "locking" part of the AccessHandle proposal in #310 for arbitrary files, even if the "in-place" behavior of that API will be limited to files on the origin private file system. There is of course the problem as mentioned that actually locking files might not always be possible, but that might be better than nothing?
For anyone looking at this, I've come up with a few ways to implement this at the application level (obviously not ideal since it doesn't prevent external applications from violating the lock guarantees):
There is currently no way to prevent more than one user from writing to a file that is currently being worked on with the Native File System API. This causes a problem when multiple users are editing the same file on a shared network drive. If User B opens a file after user A, user B can save changes whilst user A is still working on the same document. Once user A saves the file, changes made by user B are overwritten, causing data loss.
This is not possible in Excel, for example, where changes to a file are prevented whilst open by another process.
Is there a way to work around this issue?