From 09861cf4f75e2bb9e5597f8b9ea39ab4a33bf4d8 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 31 Oct 2011 15:12:02 -0400 Subject: cleanup --- Command/SetContent.hs | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'Command') diff --git a/Command/SetContent.hs b/Command/SetContent.hs index 0ecfa34bd..b63cc9119 100644 --- a/Command/SetContent.hs +++ b/Command/SetContent.hs @@ -11,7 +11,6 @@ import Common.Annex import Command import Logs.Location import Annex.Content -import qualified Backend import qualified Command.Fsck def :: [Command] @@ -28,22 +27,18 @@ start (src:dest:[]) = do start _ = error "specify a src file and a dest file" perform :: FilePath -> FilePath -> CommandPerform -perform src dest = go =<< Backend.lookupFile dest +perform src dest = isAnnexed dest $ \(key, backend) -> do + unlessM (move key) $ error "mv failed!" + next $ cleanup key backend where - go Nothing = error "dest file is not in annex" - go (Just (key, backend)) = do - -- the file might be on a different filesystem, - -- so mv is used rather than simply calling - -- moveToObjectDir; disk space is also - -- checked this way. - ok <- getViaTmp key $ \tmp -> - if dest /= src - then liftIO $ - boolSystem "mv" [File src, File tmp] - else return True - if ok - then next $ cleanup key backend - else error "mv failed!" + -- 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 -> + if dest /= src + then liftIO $ boolSystem "mv" [File src, File tmp] + else return True cleanup :: Key -> Backend Annex -> CommandCleanup cleanup key backend = do -- cgit v1.2.3