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.
This commit is contained in:
parent
28b29f63dc
commit
069d90eab5
1 changed files with 10 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue