summaryrefslogtreecommitdiff
path: root/Command/Drop.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-11-10 23:35:08 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-11-10 23:45:14 -0400
commitb327227ba596d4fc5012138d03390c3eb861b808 (patch)
tree921c3ca6851d1ede45c387d9fd54997dcbf44906 /Command/Drop.hs
parent4389782628a1cc683ef238e848b6311fc4bd82c3 (diff)
better limiting of start actions to only run whenAnnexed
Mostly only refactoring, but this does remove one redundant stat of the symlink by copy.
Diffstat (limited to 'Command/Drop.hs')
-rw-r--r--Command/Drop.hs25
1 files changed, 12 insertions, 13 deletions
diff --git a/Command/Drop.hs b/Command/Drop.hs
index 44685ffcd..ee3583869 100644
--- a/Command/Drop.hs
+++ b/Command/Drop.hs
@@ -22,20 +22,19 @@ def = [dontCheck fromOpt $ command "drop" paramPaths seek
"indicate content of files not currently wanted"]
seek :: [CommandSeek]
-seek = [withNumCopies start]
+seek = [withNumCopies $ \n -> whenAnnexed $ start n]
-start :: FilePath -> Maybe Int -> CommandStart
-start file numcopies = isAnnexed file $ \(key, _) ->
- autoCopies key (>) numcopies $ do
- from <- Annex.getState Annex.fromremote
- case from of
- Nothing -> startLocal file numcopies key
- Just name -> do
- remote <- Remote.byName name
- u <- getUUID
- if Remote.uuid remote == u
- then startLocal file numcopies key
- else startRemote file numcopies key remote
+start :: Maybe Int -> FilePath -> (Key, Backend Annex) -> CommandStart
+start numcopies file (key, _) = autoCopies key (>) numcopies $ do
+ from <- Annex.getState Annex.fromremote
+ case from of
+ Nothing -> startLocal file numcopies key
+ Just name -> do
+ remote <- Remote.byName name
+ u <- getUUID
+ if Remote.uuid remote == u
+ then startLocal file numcopies key
+ else startRemote file numcopies key remote
startLocal :: FilePath -> Maybe Int -> Key -> CommandStart
startLocal file numcopies key = do