From f5532be9540a146f18aa24bd61cd4e96c37e82f8 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 7 Jun 2024 14:56:44 -0400 Subject: [PATCH] graft in exported tree before updating the export log It was possible for the export.log to get written and then git-annex was interrupted, before it could graft in the exported tree. Which could result in export.log referencing a tree that got garbage collected. --- Logs/Export.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Logs/Export.hs b/Logs/Export.hs index 36d6156c75..0caaf6d84a 100644 --- a/Logs/Export.hs +++ b/Logs/Export.hs @@ -66,19 +66,19 @@ recordExportBeginning remoteuuid newtree = do . parseExportLogMap <$> Annex.Branch.get exportLog let new = updateIncompleteExportedTreeish old (nub (newtree:incompleteExportedTreeishes [old])) + rememberExportTreeish newtree Annex.Branch.change (Annex.Branch.RegardingUUID [remoteuuid, u]) exportLog (buildExportLog . changeMapLog c ep new . parseExportLog) - recordExportTreeish newtree -- Graft a tree ref into the git-annex branch. This is done -- to ensure that it's available later, when getting exported files -- from the remote. Since that could happen in another clone of the -- repository, the tree has to be kept available, even if it -- doesn't end up being merged into the master branch. -recordExportTreeish :: Git.Ref -> Annex () -recordExportTreeish t = void $ +rememberExportTreeish :: Git.Ref -> Annex () +rememberExportTreeish t = void $ Annex.Branch.rememberTreeish t (asTopFilePath exportTreeGraftPoint) -- | Record that an export to a special remote is under way. @@ -112,7 +112,7 @@ recordExportUnderway remoteuuid ec = do recordExport :: UUID -> Git.Ref -> ExportChange -> Annex () recordExport remoteuuid tree ec = do when (oldTreeish ec /= [tree]) $ - recordExportTreeish tree + rememberExportTreeish tree recordExportUnderway remoteuuid ec logExportExcluded :: UUID -> ((Git.Tree.TreeItem -> IO ()) -> Annex a) -> Annex a