aboutsummaryrefslogtreecommitdiff
path: root/Command/Unlock.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-08-09 11:09:54 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-08-09 11:09:54 -0400
commit425730f03a68cfa6a0e43a88c83f3470d8724627 (patch)
tree3f4e4af9dcdbe493bdbfd49c3a28724920105497 /Command/Unlock.hs
parentcdd236595fd3453901809a079fb2f06a3a502133 (diff)
unlock: Better error handling; continue past files that are not available or cannot be unlocked due to disk space, and try all specified files.
Diffstat (limited to 'Command/Unlock.hs')
-rw-r--r--Command/Unlock.hs16
1 files changed, 10 insertions, 6 deletions
diff --git a/Command/Unlock.hs b/Command/Unlock.hs
index 0070410a6..8cc72f3a3 100644
--- a/Command/Unlock.hs
+++ b/Command/Unlock.hs
@@ -26,15 +26,17 @@ seek = withFilesInGit $ whenAnnexed start
{- The unlock subcommand replaces the symlink with a copy of the file's
- content. -}
start :: FilePath -> Key -> CommandStart
-start file key = do
+start file key = stopUnless (inAnnex key) $ do
showStart "unlock" file
- next $ perform file key
+ ifM (checkDiskSpace Nothing key 0)
+ ( next $ perform file key
+ , do
+ warning "not enough disk space to copy file"
+ next $ next $ return False
+ )
perform :: FilePath -> Key -> CommandPerform
perform dest key = do
- unlessM (inAnnex key) $ error "content not present"
- unlessM (checkDiskSpace Nothing key 0) $ error "cannot unlock"
-
src <- calcRepo $ gitAnnexLocation key
tmpdest <- fromRepo $ gitAnnexTmpObjectLocation key
liftIO $ createDirectoryIfMissing True (parentDir tmpdest)
@@ -46,5 +48,7 @@ perform dest key = do
moveFile tmpdest dest
thawContent dest
next $ return True
- , error "copy failed!"
+ , do
+ warning "copy failed!"
+ next $ return False
)