From 59c9eda9624a9d35f44400104e8f022afb0f2f7e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 14 Jan 2011 00:02:33 -0400 Subject: on second thought, unlock should fail if content is not present --- Command/Unlock.hs | 13 +++++++------ test.hs | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Command/Unlock.hs b/Command/Unlock.hs index 7c1625bf0..4bd6e8599 100644 --- a/Command/Unlock.hs +++ b/Command/Unlock.hs @@ -7,6 +7,7 @@ module Command.Unlock where +import Control.Monad (when) import Control.Monad.State (liftIO) import System.Directory hiding (copyFile) @@ -32,15 +33,15 @@ seek = [withFilesInGit start] - content. -} start :: CommandStartString start file = isAnnexed file $ \(key, _) -> do - inbackend <- Backend.hasKey key - if not inbackend - then return Nothing - else do - showStart "unlock" file - return $ Just $ perform file key + showStart "unlock" file + return $ Just $ perform file key perform :: FilePath -> Key -> CommandPerform perform dest key = do + inbackend <- Backend.hasKey key + when (not inbackend) $ + error "content not present" + g <- Annex.gitRepo let src = annexLocation g key liftIO $ removeFile dest diff --git a/test.hs b/test.hs index ee29855b4..2504bc797 100644 --- a/test.hs +++ b/test.hs @@ -218,7 +218,7 @@ test_lock = "git-annex unlock/lock" ~: intmpclonerepo $ do -- regression test: unlock of not present file should skip it annexed_notpresent annexedfile r <- git_annex "unlock" ["-q", annexedfile] - r @? "unlock failed with not present file" + not r @? "unlock failed to fail with not present file" annexed_notpresent annexedfile git_annex "get" ["-q", annexedfile] @? "get of file failed" -- cgit v1.2.3