summaryrefslogtreecommitdiff
path: root/Command/DropUnused.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-12-03 15:58:00 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-12-03 15:58:00 -0400
commit01bf5a9ec04c2e6711e33d6b43562528d3ab7ae4 (patch)
treedfed7b4139f1e109c5b477fc7ded075a89621340 /Command/DropUnused.hs
parent4e853cf9ea98408c37584fbf9a153822e9fbde10 (diff)
dropunused: Make more robust when trying to drop an object that has already been dropped.
Before it crashed trying to lock the not-present content and prevented dropping anything else. Instead, succeed.
Diffstat (limited to 'Command/DropUnused.hs')
-rw-r--r--Command/DropUnused.hs11
1 files changed, 9 insertions, 2 deletions
diff --git a/Command/DropUnused.hs b/Command/DropUnused.hs
index 9c2ae972a..d9f02a370 100644
--- a/Command/DropUnused.hs
+++ b/Command/DropUnused.hs
@@ -14,6 +14,7 @@ import qualified Remote
import qualified Git
import Command.Unused (withUnusedMaps, UnusedMaps(..), startUnused)
import Annex.NumCopies
+import Annex.Content
cmd :: Command
cmd = command "dropunused" SectionMaintenance
@@ -37,14 +38,20 @@ seek o = do
withUnusedMaps (start from numcopies) (rangesToDrop o)
start :: Maybe Remote -> NumCopies -> UnusedMaps -> Int -> CommandStart
-start from numcopies = startUnused "dropunused" (perform from numcopies) (performOther gitAnnexBadLocation) (performOther gitAnnexTmpObjectLocation)
+start from numcopies = startUnused "dropunused"
+ (perform from numcopies)
+ (performOther gitAnnexBadLocation)
+ (performOther gitAnnexTmpObjectLocation)
perform :: Maybe Remote -> NumCopies -> Key -> CommandPerform
perform from numcopies key = case from of
Just r -> do
showAction $ "from " ++ Remote.name r
Command.Drop.performRemote key Nothing numcopies r
- Nothing -> Command.Drop.performLocal key Nothing numcopies []
+ Nothing -> ifM (inAnnex key)
+ ( Command.Drop.performLocal key Nothing numcopies []
+ , next (return True)
+ )
performOther :: (Key -> Git.Repo -> FilePath) -> Key -> CommandPerform
performOther filespec key = do