diff options
author | Joey Hess <joey@kitenet.net> | 2011-11-10 23:35:08 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-11-10 23:45:14 -0400 |
commit | b327227ba596d4fc5012138d03390c3eb861b808 (patch) | |
tree | 921c3ca6851d1ede45c387d9fd54997dcbf44906 /Command/Reinject.hs | |
parent | 4389782628a1cc683ef238e848b6311fc4bd82c3 (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/Reinject.hs')
-rw-r--r-- | Command/Reinject.hs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Command/Reinject.hs b/Command/Reinject.hs index 1277edf90..cfa0655ef 100644 --- a/Command/Reinject.hs +++ b/Command/Reinject.hs @@ -25,19 +25,19 @@ start (src:dest:[]) | src == dest = stop | otherwise = do showStart "reinject" dest - next $ perform src dest + next $ whenAnnexed (perform src) dest start _ = error "specify a src file and a dest file" -perform :: FilePath -> FilePath -> CommandPerform -perform src dest = isAnnexed dest $ \(key, backend) -> do - unlessM (move key) $ error "mv failed!" +perform :: FilePath -> FilePath -> (Key, Backend Annex) -> CommandPerform +perform src _dest (key, backend) = do + unlessM move $ error "mv failed!" next $ cleanup key backend where -- the file might be on a different filesystem, -- so mv is used rather than simply calling -- moveToObjectDir; disk space is also -- checked this way. - move key = getViaTmp key $ \tmp -> + move = getViaTmp key $ \tmp -> liftIO $ boolSystem "mv" [File src, File tmp] cleanup :: Key -> Backend Annex -> CommandCleanup |