From: Joey Hess Date: Fri, 2 Aug 2024 20:45:52 +0000 (-0400) Subject: prevent removeKey from annexobjects=yes remote when the key is in the exported tree X-Git-Tag: archive/raspbian/10.20250416-2+rpi1~1^2~21^2~159^2~31 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=069d90eab52f99ea5966f459e28479216c510089;p=git-annex.git prevent removeKey from annexobjects=yes remote when the key is in the exported tree Removing the key from the annexobjects location when it's in the exported tree would leave it in the exported tree, and so succeeding would update the location log incorrectly. But this also can't remove it from the exported tree, because that would cause import tree to see a file got deleted. So, refuse to remove in this situation. It would be possible to remove from the annexobjects location and then fail. Then if a key somehow got stored in both the annexobjects location and the exported tree location(s), the duplicate would be resolved. Not doing this because first, I don't know how that situation could happen, and second, it seems wrong for a failed remove to have a side-effect like that. --- diff --git a/Remote/Helper/ExportImport.hs b/Remote/Helper/ExportImport.hs index 6840055f6f..73137c728a 100644 --- a/Remote/Helper/ExportImport.hs +++ b/Remote/Helper/ExportImport.hs @@ -175,7 +175,7 @@ adjustExportImport' isexport isimport annexobjects r rs gc = do then giveup "dropping content from this remote is not supported" else if isexport then if annexobjects - then removeannexobject k + then removeannexobject dbv k else giveup "dropping content from an export is not supported; use `git annex export` to export a tree that lacks the files you want to remove" else if isimport then giveup "dropping content from this remote is not supported because it is configured with importtree=yes" @@ -427,8 +427,15 @@ adjustExportImport' isexport isimport annexobjects r rs gc = do removeExport (exportActions r) k loc giveup err - removeannexobject k = - removeExport (exportActions r) k (annexobjectlocation k) + removeannexobject dbv k = + getanyexportlocs dbv k >>= \case + [] -> ifM (isexportinconflict dbv) + ( do + warnExportImportConflict r + giveup "Cannot remove content from the remote until the conflict has been resolved." + , removeExport (exportActions r) k (annexobjectlocation k) + ) + _ -> giveup "This key is part of the exported tree, so can only be removed by exporting a tree that does not include it." retrieveannexobject k dest p = retrieveExport (exportActions r) k (annexobjectlocation k) dest p