createDirectoryIfMissing True creates any missing parent directories. So if the git repository directory goes away suddenly, git-annex can create a new empty directory in its place and start putting files in there.

  • I've seen this happen when a removable drive that's a remote is unmounted and git-annex is running and stores a file on the remote. Since git-annex's cwd is not on the remote and it may not have any files open when it's unmounted, the unmount proceeds. When the mount point is /media/username/drive, the automounter may delete the mount point, and git-annex then recreates it and may write files to it, which is the wrong location. This can also cause problems with later mounting of the drive; some automounters fail if the mount point pre-exists.

  • A move of a directory to another path can also lead to git-annex writing to the old path and re-creating the directory. While it mostly uses relative paths to cwd, and so is fine, there may be cases where it needs to use an absolute path.

  • Odd behavior has been reported if the repository is deleted while git-annex is running it it. Including a git-annex seeming to hang or spin. https://github.com/datalad/datalad/issues/3613

    The sooner git-annex gives up in such a situation, the less likely it is do get into an unusual state.

What's needed is an action that creates directories only up to a given point, which can be either .git/annex or the top of the worktree depending on what's being done. --Joey