diff options
author | Joey Hess <joey@kitenet.net> | 2014-03-22 15:01:48 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-03-22 15:01:48 -0400 |
commit | 123c9520fb9a4197761cb57e17605eed2bb882ec (patch) | |
tree | 2169d91592d016c6e62096ada6434a885953c40a /Command | |
parent | 6af20ba3f858165743a8bad35388be12c498cf5f (diff) |
notifications on drop
Diffstat (limited to 'Command')
-rw-r--r-- | Command/Drop.hs | 19 | ||||
-rw-r--r-- | Command/DropUnused.hs | 2 |
2 files changed, 14 insertions, 7 deletions
diff --git a/Command/Drop.hs b/Command/Drop.hs index d29195b05..f6c1880e9 100644 --- a/Command/Drop.hs +++ b/Command/Drop.hs @@ -17,6 +17,7 @@ import Logs.Trust import Config.NumCopies import Annex.Content import Annex.Wanted +import Annex.Notification def :: [Command] def = [withOptions [dropFromOption] $ command "drop" paramPaths seek @@ -44,24 +45,30 @@ start from file (key, _) = checkDropAuto from file key $ \numcopies -> startLocal :: AssociatedFile -> NumCopies -> Key -> Maybe Remote -> CommandStart startLocal afile numcopies key knownpresentremote = stopUnless (inAnnex key) $ do showStart' "drop" key afile - next $ performLocal key numcopies knownpresentremote + next $ performLocal key afile numcopies knownpresentremote startRemote :: AssociatedFile -> NumCopies -> Key -> Remote -> CommandStart startRemote afile numcopies key remote = do showStart' ("drop " ++ Remote.name remote) key afile next $ performRemote key numcopies remote -performLocal :: Key -> NumCopies -> Maybe Remote -> CommandPerform -performLocal key numcopies knownpresentremote = lockContent key $ do +performLocal :: Key -> AssociatedFile -> NumCopies -> Maybe Remote -> CommandPerform +performLocal key afile numcopies knownpresentremote = lockContent key $ do (remotes, trusteduuids) <- Remote.keyPossibilitiesTrusted key let trusteduuids' = case knownpresentremote of Nothing -> trusteduuids Just r -> nub (Remote.uuid r:trusteduuids) untrusteduuids <- trustGet UnTrusted let tocheck = Remote.remotesWithoutUUID remotes (trusteduuids'++untrusteduuids) - stopUnless (canDropKey key numcopies trusteduuids' tocheck []) $ do - removeAnnex key - next $ cleanupLocal key + ifM (canDropKey key numcopies trusteduuids' tocheck []) + ( do + removeAnnex key + notifyDrop afile True + next $ cleanupLocal key + , do + notifyDrop afile False + stop + ) performRemote :: Key -> NumCopies -> Remote -> CommandPerform performRemote key numcopies remote = lockContent key $ do diff --git a/Command/DropUnused.hs b/Command/DropUnused.hs index 345d03032..5d1923d34 100644 --- a/Command/DropUnused.hs +++ b/Command/DropUnused.hs @@ -35,7 +35,7 @@ perform numcopies key = maybe droplocal dropremote =<< Remote.byNameWithUUID =<< dropremote r = do showAction $ "from " ++ Remote.name r Command.Drop.performRemote key numcopies r - droplocal = Command.Drop.performLocal key numcopies Nothing + droplocal = Command.Drop.performLocal key Nothing numcopies Nothing from = Annex.getField $ optionName Command.Drop.dropFromOption performOther :: (Key -> Git.Repo -> FilePath) -> Key -> CommandPerform |