cleanup
This commit is contained in:
parent
380839299e
commit
09861cf4f7
1 changed files with 11 additions and 16 deletions
|
@ -11,7 +11,6 @@ import Common.Annex
|
||||||
import Command
|
import Command
|
||||||
import Logs.Location
|
import Logs.Location
|
||||||
import Annex.Content
|
import Annex.Content
|
||||||
import qualified Backend
|
|
||||||
import qualified Command.Fsck
|
import qualified Command.Fsck
|
||||||
|
|
||||||
def :: [Command]
|
def :: [Command]
|
||||||
|
@ -28,22 +27,18 @@ start (src:dest:[]) = do
|
||||||
start _ = error "specify a src file and a dest file"
|
start _ = error "specify a src file and a dest file"
|
||||||
|
|
||||||
perform :: FilePath -> FilePath -> CommandPerform
|
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
|
where
|
||||||
go Nothing = error "dest file is not in annex"
|
|
||||||
go (Just (key, backend)) = do
|
|
||||||
-- the file might be on a different filesystem,
|
-- the file might be on a different filesystem,
|
||||||
-- so mv is used rather than simply calling
|
-- so mv is used rather than simply calling
|
||||||
-- moveToObjectDir; disk space is also
|
-- moveToObjectDir; disk space is also
|
||||||
-- checked this way.
|
-- checked this way.
|
||||||
ok <- getViaTmp key $ \tmp ->
|
move key = getViaTmp key $ \tmp ->
|
||||||
if dest /= src
|
if dest /= src
|
||||||
then liftIO $
|
then liftIO $ boolSystem "mv" [File src, File tmp]
|
||||||
boolSystem "mv" [File src, File tmp]
|
|
||||||
else return True
|
else return True
|
||||||
if ok
|
|
||||||
then next $ cleanup key backend
|
|
||||||
else error "mv failed!"
|
|
||||||
|
|
||||||
cleanup :: Key -> Backend Annex -> CommandCleanup
|
cleanup :: Key -> Backend Annex -> CommandCleanup
|
||||||
cleanup key backend = do
|
cleanup key backend = do
|
||||||
|
|
Loading…
Add table
Reference in a new issue