diff --git a/Annex/Import.hs b/Annex/Import.hs index cda82022a9..6a71538563 100644 --- a/Annex/Import.hs +++ b/Annex/Import.hs @@ -982,14 +982,22 @@ importKeys remote importtreeconfig importcontent thirdpartypopulated importablec ImportSubTree subdir _ -> getTopFilePath subdir fromImportLocation loc - getcidkey cidmap db cid = liftIO $ + getcidkey cidmap db cid = do -- Avoiding querying the database when it's empty speeds up -- the initial import. - if CIDDb.databaseIsEmpty db + l <- liftIO $ if CIDDb.databaseIsEmpty db then getcidkeymap cidmap cid else CIDDb.getContentIdentifierKeys db rs cid >>= \case [] -> getcidkeymap cidmap cid l -> return l + filterM validcidkey l + + -- Guard against a content identifier containing a git sha that is + -- not present in the repository. It's possible that it's not, + -- when git-annex forget is used. + validcidkey k = case keyGitSha k of + Just sha -> isJust <$> catObjectMetaData sha + Nothing -> return True getcidkeymap cidmap cid = atomically $ maybeToList . M.lookup cid <$> readTVar cidmap diff --git a/CHANGELOG b/CHANGELOG index cd6231b075..a8ada4f875 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,8 @@ git-annex (10.20251216) UNRELEASED; urgency=medium on network-multicast or network-info. * stack.yaml: Update to lts-24.26. * import: Fix display of some import errors. + * Fix bug importing a tree from a remote after git-annex forget has been + used, that could result in the imported tree mising git blobs. -- Joey Hess Thu, 01 Jan 2026 12:20:29 -0400 diff --git a/doc/bugs/s3_imported_branch_is___34__git_buggy__34____58____bad_blobs/comment_8_4d86764ebd02d547cad7eebbcd116759._comment b/doc/bugs/s3_imported_branch_is___34__git_buggy__34____58____bad_blobs/comment_8_4d86764ebd02d547cad7eebbcd116759._comment new file mode 100644 index 0000000000..52156dd365 --- /dev/null +++ b/doc/bugs/s3_imported_branch_is___34__git_buggy__34____58____bad_blobs/comment_8_4d86764ebd02d547cad7eebbcd116759._comment @@ -0,0 +1,7 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 8""" + date="2026-01-02T15:59:56Z" + content=""" +I've made it deal with the `git-annex forget` scenario now. +"""]]