fix rekey/migrate bookkeeping in v6
After 220317df5a
the test suite still
detected a problem; migrate of an unlocked file replaced it with a
pointer file rather than a file with the content.
This was a bookeeping problem; the worktree file was being copied to the object
file and the inode cache updated, but if that database write didn't get
flushed in time, later checks would think the content was not present.
Fixed by copying the object file to the worktree file instead, which
avoids needing to update the inode cache.
Also, only copy when there's a hard link to break, not always.
This commit was sponsored by Brock Spratlen on Patreon.
This commit is contained in:
parent
220317df5a
commit
558520d27a
1 changed files with 10 additions and 10 deletions
|
@ -87,17 +87,17 @@ linkKey file oldkey newkey = ifM (isJust <$> isAnnexLink file)
|
|||
oldobj <- calcRepo (gitAnnexLocation oldkey)
|
||||
isJust <$> linkOrCopy' (return True) newkey oldobj tmp Nothing
|
||||
, do
|
||||
{- The file being rekeyed is itself an unlocked file, so if
|
||||
- it's linked to the old key, that link must be broken. -}
|
||||
{- The file being rekeyed is itself an unlocked file; if
|
||||
- it's hard linked to the old key, that link must be broken. -}
|
||||
oldobj <- calcRepo (gitAnnexLocation oldkey)
|
||||
v <- tryNonAsync $ modifyContent oldobj $ do
|
||||
replaceFile oldobj $ \tmp ->
|
||||
unlessM (checkedCopyFile oldkey file tmp Nothing) $
|
||||
error "can't lock old key"
|
||||
freezeContent oldobj
|
||||
oldic <- withTSDelta (liftIO . genInodeCache oldobj)
|
||||
whenM (isUnmodified oldkey oldobj) $
|
||||
Database.Keys.addInodeCaches oldkey (catMaybes [oldic])
|
||||
v <- tryNonAsync $ do
|
||||
st <- liftIO $ getFileStatus file
|
||||
when (linkCount st > 1) $ do
|
||||
freezeContent oldobj
|
||||
replaceFile file $ \tmp -> do
|
||||
unlessM (checkedCopyFile oldkey oldobj tmp Nothing) $
|
||||
error "can't lock old key"
|
||||
thawContent tmp
|
||||
ic <- withTSDelta (liftIO . genInodeCache file)
|
||||
case v of
|
||||
Left e -> do
|
||||
|
|
Loading…
Reference in a new issue