Make lock and unlock work in v6 repos on files whose content is not present.
This commit is contained in:
parent
0249f3aff5
commit
0bc7fee660
4 changed files with 18 additions and 15 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue