assistant: Fix a crash when a small file is deleted immediately after being created
authorJoey Hess <joeyh@joeyh.name>
Mon, 19 Jun 2023 16:09:18 +0000 (12:09 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 19 Jun 2023 16:44:56 +0000 (12:44 -0400)
commit217a6abb19402d3e4d1945091a9e25f029cce365
treef6794e118fbeea1fca68aa7f51d0fdf780274136
parent553962eb475d673c17e7ac4c9515dc922c268c3d
assistant: Fix a crash when a small file is deleted immediately after being created

git add will fail if the file got deleted in the meantime. And since it was
queued, there was a window until the queue flushed where a deletion of the
file would cause a crash.

Instead, reuse Command.Add.addFile, which sha1 hashes the file itself
immediately, and then queues the index update. Ignore exceptions that will
happen if the file got deleted already.

Sponsored-by: k0ld on Patreon
Assistant/Threads/Committer.hs
CHANGELOG
doc/bugs/assistant_committer_crashes_due_to_missing_file.mdwn