v6: fix migrate of unlocked file

After commit b2bafdb2fc the test suite
threw up a failure migrating unlocked files.

I'm not clear how that commit broke it (presumably by inAnnex reporting
the right information now), but the actual problem is plain:
The inodecache for the worktree file is generated, but then the file is
replaced with a copy (unncessarily unless annex.link is set, but the
code always does so) and so linkToAnnex/linkAnnex then fails because it
notices the inode cache is not valid.

This commit was sponsored by Jake Vosloo on Patreon.
This commit is contained in:
Joey Hess 2018-10-16 16:45:08 -04:00
parent bdf6783b92
commit 220317df5a
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -87,7 +87,6 @@ linkKey file oldkey newkey = ifM (isJust <$> isAnnexLink file)
oldobj <- calcRepo (gitAnnexLocation oldkey) oldobj <- calcRepo (gitAnnexLocation oldkey)
isJust <$> linkOrCopy' (return True) newkey oldobj tmp Nothing isJust <$> linkOrCopy' (return True) newkey oldobj tmp Nothing
, do , do
ic <- withTSDelta (liftIO . genInodeCache file)
{- The file being rekeyed is itself an unlocked file, so if {- The file being rekeyed is itself an unlocked file, so if
- it's linked to the old key, that link must be broken. -} - it's linked to the old key, that link must be broken. -}
oldobj <- calcRepo (gitAnnexLocation oldkey) oldobj <- calcRepo (gitAnnexLocation oldkey)
@ -99,6 +98,7 @@ linkKey file oldkey newkey = ifM (isJust <$> isAnnexLink file)
oldic <- withTSDelta (liftIO . genInodeCache oldobj) oldic <- withTSDelta (liftIO . genInodeCache oldobj)
whenM (isUnmodified oldkey oldobj) $ whenM (isUnmodified oldkey oldobj) $
Database.Keys.addInodeCaches oldkey (catMaybes [oldic]) Database.Keys.addInodeCaches oldkey (catMaybes [oldic])
ic <- withTSDelta (liftIO . genInodeCache file)
case v of case v of
Left e -> do Left e -> do
warning (show e) warning (show e)