How to enable atomic file operations for Upload and Save #3146
gingerbeardman
started this conversation in
Show and tell
Replies: 1 comment 1 reply
-
I can't imagine linux having a problem with a cached version of a file being ignored to put a different version on the disk hardware. If this were a problem, it would be showing up all over the place and be a major annoyance, and not just with filebrowser. Can you describe a scenario where this actually happens? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Background
By default
filebrowser
make changed to files in-place. This is known as a non-atomic file operation. The benefits are that it is quicker, but the problems are that the web server may not know that the file has changed and serve a cached version, or worse serve a truncated version, or some bad data when the updated file is larger or smaller than the original.Solution
filebrowser
offers some settings mechanisms to get around this: Settings > Global Settings > Command runnerWe can use the Command runner to achieve atomic file operations for upload (replacing files with a new version) and save (using the built-in text editor) by deleting the original file before the action completes.
Upload (replacing files with a new version)
Before Upload:
Save (using the built-in text editor)
Before Save:
Save (using the built-in text editor), alternative:
Before Save:
After Save:
Ideally I'd only delete the backup file if the new file has been successfully created, but I've not been able to get that to work (After Save I'd want do
test -f "$FILE" && rm "$FILE.bak"
to achieve this, but it gave a server error)Beta Was this translation helpful? Give feedback.
All reactions