summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-10-31 15:12:02 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-10-31 15:12:02 -0400
commit09861cf4f75e2bb9e5597f8b9ea39ab4a33bf4d8 (patch)
treeea6ad71e1be3dce27a93ce3c0290e3c0e8aaaa68 /Command
parent380839299ea8ffa2c98ce6219e62b979ede0c93b (diff)
cleanup
Diffstat (limited to 'Command')
-rw-r--r--Command/SetContent.hs27
1 files changed, 11 insertions, 16 deletions
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