fix test suite

14683da9eb caused a test suite failure.
When the content of a key is not present, a LinkAnnexFailed is returned,
but replaceFile then tried to move the file into place, and since it was
not written, that crashed.

Sponsored-by: Boyd Stephen Smith Jr. on Patreon
This commit is contained in:
Joey Hess 2021-08-02 13:59:23 -04:00
parent 86bd9ac186
commit 6111958440
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 10 additions and 4 deletions

View file

@ -374,6 +374,7 @@ checkSecureHashes' key = checkSecureHashes key >>= \case
return False
data LinkAnnexResult = LinkAnnexOk | LinkAnnexFailed | LinkAnnexNoop
deriving (Eq)
{- Populates the annex object file by hard linking or copying a source
- file to it. -}
@ -396,7 +397,7 @@ linkToAnnex key src srcic = ifM (checkSecureHashes' key)
-}
linkFromAnnex :: Key -> RawFilePath -> Maybe FileMode -> Annex LinkAnnexResult
linkFromAnnex key dest destmode =
replaceFile (const noop) (fromRawFilePath dest) $ \tmp ->
replaceFile' (const noop) (fromRawFilePath dest) (== LinkAnnexOk) $ \tmp ->
linkFromAnnex' key (toRawFilePath tmp) destmode
{- This is only safe to use when dest is not a worktree file. -}