From 217a6abb19402d3e4d1945091a9e25f029cce365 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 19 Jun 2023 12:09:18 -0400 Subject: [PATCH] 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 | 9 ++++++--- CHANGELOG | 2 ++ .../assistant_committer_crashes_due_to_missing_file.mdwn | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Assistant/Threads/Committer.hs b/Assistant/Threads/Committer.hs index 62341564f6..5a3a88b47d 100644 --- a/Assistant/Threads/Committer.hs +++ b/Assistant/Threads/Committer.hs @@ -1,6 +1,6 @@ {- git-annex assistant commit thread - - - Copyright 2012-2021 Joey Hess + - Copyright 2012-2023 Joey Hess - - Licensed under the GNU AGPL version 3 or higher. -} @@ -38,6 +38,7 @@ import qualified Annex import Utility.InodeCache import qualified Database.Keys import qualified Command.Sync +import qualified Command.Add import Config.GitConfig import Utility.Tuple import Utility.Metered @@ -303,8 +304,10 @@ handleAdds lockdowndir havelsof largefilematcher annexdotfiles delayadd cs = ret f = toRawFilePath (changeFile change) addsmall [] = noop - addsmall toadd = liftAnnex $ Annex.Queue.addCommand [] "add" - [ Param "--force", Param "--"] (map changeFile toadd) + addsmall toadd = liftAnnex $ void $ tryIO $ + forM (map (toRawFilePath . changeFile) toadd) $ \f -> + Command.Add.addFile Command.Add.Small f + =<< liftIO (R.getSymbolicLinkStatus f) {- Avoid overhead of re-injesting a renamed unlocked file, by - examining the other Changes to see if a removed file has the diff --git a/CHANGELOG b/CHANGELOG index 941fe562cd..5f10ba25a7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -91,6 +91,8 @@ git-annex (10.20230408) UNRELEASED; urgency=medium * config: Added the --show-origin and --for-file options. * config: Support annex.numcopies and annex.mincopies. * Fix display when run with -J1. + * assistant: Fix a crash when a small file is deleted immediately after + being created. -- Joey Hess Sat, 08 Apr 2023 13:57:18 -0400 diff --git a/doc/bugs/assistant_committer_crashes_due_to_missing_file.mdwn b/doc/bugs/assistant_committer_crashes_due_to_missing_file.mdwn index 36f45d8183..c32d333ce3 100644 --- a/doc/bugs/assistant_committer_crashes_due_to_missing_file.mdwn +++ b/doc/bugs/assistant_committer_crashes_due_to_missing_file.mdwn @@ -67,3 +67,5 @@ Committer crashed: user error (xargs ["-0","git","--git-dir=.git","--work-tree=. # End of transcript or log. """]] + +> [[fixed|done]] --[[Joey]]