Please describe the problem.
On OS X 10.11.6, if you save any MS office file (.pptx, .docx, .xlsx) in a git-annex directory it won't be synced by the assistant unless you restart the daemon. If you look in the logs it says "/Users/me/annex/test.pptx still has writers, not adding" This probably has something to do with temporary/lockfiles used by MS office apps (Office 2011 for Mac). Any ideas on a workaround, other than restarting the daemon constantly?
What steps will reproduce the problem?
- Create any MS office file (.docx, .pptx, .xlsx). Save in a directory managed by git-annex assistant. Error message "still has writers, not adding" will show up in git-annex log. File will not be synced to any other computer running git-annex assistant until Office application quit and daemon restarted.
What version of git-annex are you using? On what operating system?
6.20161211-gf58b134, OS X 10.11.6
Please provide any additional information below.
# If you can, paste a complete transcript of the problem occurring here.
# If the problem is with the git-annex assistant, paste in .git/annex/daemon.log
# End of transcript or log.
Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)
Yes! It's wonderful otherwise!
This must have to do with the fsevents interface used on OSX.
In Assistant.Threads.Committer.safeToAdd, when lsof detects a file is still open for write by some process, it cancels the add. This relies on events being received when files get closed (closingTracked).
In Utility.DirWatcher.FSEvents.watchDir, when an event has eventFlagItemModified set, it treats that as a file add event. The intent is to emulate inotify's handling of file add events when files are closed.
So, two theories:
Perhaps eventFlagItemModified only gets set if the file is actually modified. Ie, if MS office writes the file and while it's being written another process opens it to read it (perhaps to index the content), then if the other process doesn't modify it, eventFlagItemModified is not set.
Perhaps the way the assistant hard links/moves the file around confuses the FSEvents handling. Perhaps there is an event with eventFlagItemModified, but it's for the locked down file, or something like that, so git-annex ignores it.
In any case, I'm leaning toward thinking that closingTracked should not be True for FSEvents. This bug report seems to show, conclusively, that FSEvents does not have that property. If closingTracked was False, as it is for KQueue, the assistant would postpone adding the file, and keep retrying, around once per second, until it no longer had any writers, and then add it.
So, I've made that change. I suspect it fixes the bug, but it would be pretty hard for me to test it. Could you please download tomorrow's daily build of git-annex for OSX, and see if it fixes the problem?