aboutsummaryrefslogtreecommitdiff
path: root/Command/Unlock.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-06-09 14:40:44 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-06-09 14:40:44 -0400
commit3be798cc348c0869e76c02c972126403927f4475 (patch)
treef748aee098be4d1e072f867b57d045b4d1c4e503 /Command/Unlock.hs
parentacc29b6b9759794a27a0c81315fd0bd5a7f1a052 (diff)
Make lock and unlock work in v6 repos on files whose content is not present.
Diffstat (limited to 'Command/Unlock.hs')
-rw-r--r--Command/Unlock.hs26
1 files changed, 13 insertions, 13 deletions
diff --git a/Command/Unlock.hs b/Command/Unlock.hs
index 2fe1175a8..4dc02642e 100644
--- a/Command/Unlock.hs
+++ b/Command/Unlock.hs
@@ -37,14 +37,9 @@ start :: FilePath -> Key -> CommandStart
start file key = ifM (isJust <$> isAnnexLink file)
( do
showStart "unlock" file
- ifM (inAnnex key)
- ( ifM versionSupportsUnlockedPointers
- ( next $ performNew file key
- , startOld file key
- )
- , do
- warning "content not present; cannot unlock"
- next $ next $ return False
+ ifM versionSupportsUnlockedPointers
+ ( next $ performNew file key
+ , startOld file key
)
, stop
)
@@ -52,11 +47,16 @@ start file key = ifM (isJust <$> isAnnexLink file)
performNew :: FilePath -> Key -> CommandPerform
performNew dest key = do
destmode <- liftIO $ catchMaybeIO $ fileMode <$> getFileStatus dest
- replaceFile dest $ \tmp -> do
- r <- linkFromAnnex key tmp destmode
- case r of
- LinkAnnexOk -> return ()
- _ -> error "unlock failed"
+ replaceFile dest $ \tmp ->
+ ifM (inAnnex key)
+ ( do
+ r <- linkFromAnnex key tmp destmode
+ case r of
+ LinkAnnexOk -> return ()
+ LinkAnnexNoop -> return ()
+ _ -> error "unlock failed"
+ , liftIO $ writePointerFile tmp key destmode
+ )
next $ cleanupNew dest key destmode
cleanupNew :: FilePath -> Key -> Maybe FileMode -> CommandCleanup