How does git-annex-watch handle files that are actively being written? The documentation says it "takes care of automatically adding new files". Is it guaranteed to wait until a file is no longer opened for writing, before adding the file?
Also, is there a way to have newly added files be automatically copied to a specified remote?
Thanks!
Yes, it uses lsof and other strategies to avoid that problem.
The assistant handles copying files to other remotes, so use it instead of watch if you want that.
git-annex-sync
periodically. I assume it's ok to both do that and havegit-annex-watch
running in the background?git-annex-add
also check for actively-written files, and wait until they're no longer being written before adding them?It does not, mostly because it would need to run lsof once per file, which would be significantly expensive. The daemon is able to batch changes and so run lsof less often.
However, git-annex add does detect if a file is modified while it's being hashed, and will avoid adding it then. And it prevents against most ways the file could be modified except for if something has it open for write beforehand. In the worst case, the object in the annex gets written to, which later gets detected by fsck.
The assistant can display a gui, but it can also run headless.
Anyway, it's fine to use
git annex sync
or other things that move content around whilegit annex watch
is running.git-annex-add
could do a pre-pass where it finds all files to be added, chmods them to read-only to stop new open-for-write attempts, then runs lsof once to find any existing ones? The files could be hardlinked into one temp dir then chmod and lsof run on that dir.