From 398183b4e1c448d960aea76a66ccac2816f94003 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 2 Feb 2019 13:56:31 -0400 Subject: Fix race in cleanup of othertmp directory that could result in a failure attempting to access it. Need to create the directory after the lock is held, not before. The other racing process would need to shut down at just the wrong time, running cleanupOtherTmp. This commit was sponsored by Boyd Stephen Smith Jr. on Patreon. (cherry picked from commit a64fca92f6dfea086b7b9e65a2b83fb50fee1ecf) --- Annex/Tmp.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Annex/Tmp.hs b/Annex/Tmp.hs index d3a191f2dd..008b5fd826 100644 --- a/Annex/Tmp.hs +++ b/Annex/Tmp.hs @@ -27,8 +27,9 @@ withOtherTmp a = do addCleanup OtherTmpCleanup cleanupOtherTmp tmpdir <- fromRepo gitAnnexTmpOtherDir tmplck <- fromRepo gitAnnexTmpOtherLock - void $ createAnnexDirectory tmpdir - withSharedLock (const tmplck) (a tmpdir) + withSharedLock (const tmplck) $ do + void $ createAnnexDirectory tmpdir + a tmpdir -- | Cleans up any tmp files that were left by a previous -- git-annex process that got interrupted or failed to clean up after -- cgit v1.2.3