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
|
@ -28,6 +28,8 @@ git-annex (6.20160528) UNRELEASED; urgency=medium
|
||||||
that had not been synced back to master.
|
that had not been synced back to master.
|
||||||
(This bug caused broken tree objects to get built by a later git annex
|
(This bug caused broken tree objects to get built by a later git annex
|
||||||
sync.)
|
sync.)
|
||||||
|
* Make lock and unlock work in v6 repos on files whose content is not
|
||||||
|
present.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Fri, 27 May 2016 13:12:48 -0400
|
-- Joey Hess <id@joeyh.name> Fri, 27 May 2016 13:12:48 -0400
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ startNew file key = ifM (isJust <$> isAnnexLink file)
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
go (Just key')
|
go (Just key')
|
||||||
| key' == key = error "content not present; cannot lock"
|
| key' == key = cont True
|
||||||
| otherwise = errorModified
|
| otherwise = errorModified
|
||||||
go Nothing =
|
go Nothing =
|
||||||
ifM (isUnmodified key file)
|
ifM (isUnmodified key file)
|
||||||
|
|
|
@ -37,14 +37,9 @@ start :: FilePath -> Key -> CommandStart
|
||||||
start file key = ifM (isJust <$> isAnnexLink file)
|
start file key = ifM (isJust <$> isAnnexLink file)
|
||||||
( do
|
( do
|
||||||
showStart "unlock" file
|
showStart "unlock" file
|
||||||
ifM (inAnnex key)
|
ifM versionSupportsUnlockedPointers
|
||||||
( ifM versionSupportsUnlockedPointers
|
( next $ performNew file key
|
||||||
( next $ performNew file key
|
, startOld file key
|
||||||
, startOld file key
|
|
||||||
)
|
|
||||||
, do
|
|
||||||
warning "content not present; cannot unlock"
|
|
||||||
next $ next $ return False
|
|
||||||
)
|
)
|
||||||
, stop
|
, stop
|
||||||
)
|
)
|
||||||
|
@ -52,11 +47,16 @@ start file key = ifM (isJust <$> isAnnexLink file)
|
||||||
performNew :: FilePath -> Key -> CommandPerform
|
performNew :: FilePath -> Key -> CommandPerform
|
||||||
performNew dest key = do
|
performNew dest key = do
|
||||||
destmode <- liftIO $ catchMaybeIO $ fileMode <$> getFileStatus dest
|
destmode <- liftIO $ catchMaybeIO $ fileMode <$> getFileStatus dest
|
||||||
replaceFile dest $ \tmp -> do
|
replaceFile dest $ \tmp ->
|
||||||
r <- linkFromAnnex key tmp destmode
|
ifM (inAnnex key)
|
||||||
case r of
|
( do
|
||||||
LinkAnnexOk -> return ()
|
r <- linkFromAnnex key tmp destmode
|
||||||
_ -> error "unlock failed"
|
case r of
|
||||||
|
LinkAnnexOk -> return ()
|
||||||
|
LinkAnnexNoop -> return ()
|
||||||
|
_ -> error "unlock failed"
|
||||||
|
, liftIO $ writePointerFile tmp key destmode
|
||||||
|
)
|
||||||
next $ cleanupNew dest key destmode
|
next $ cleanupNew dest key destmode
|
||||||
|
|
||||||
cleanupNew :: FilePath -> Key -> Maybe FileMode -> CommandCleanup
|
cleanupNew :: FilePath -> Key -> Maybe FileMode -> CommandCleanup
|
||||||
|
|
|
@ -22,4 +22,5 @@ lock git/bup.git/bupindex.hlink git-annex: content not present; cannot lock
|
||||||
|
|
||||||
### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)
|
### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)
|
||||||
|
|
||||||
|
> Well, that was simply not implemented, but I've done so now. (unlocking
|
||||||
|
> too). [[done]] --[[Joey]]
|
||||||
|
|
Loading…
Reference in a new issue