migrate --apply

And avoid migrate --update/--aply migrating when the new key was already
present in the repository, and got dropped. Luckily, the location log
allows distinguishing from the new key never having been present!

That is mostly useful for --apply because otherwise dropped files would
keep coming back until the old objects were reaped as unused. But it
seemed to make sense to also do it for --update. for consistency in edge
cases if nothing else. One case where --update can use it is when one
branch got migrated earlier, and we dropped the file, and now another
branch has migrated the same file.

Sponsored-by: Jack Hill on Patreon
This commit is contained in:
Joey Hess 2023-12-08 13:23:03 -04:00
parent 51b974d9f0
commit 4ed71b34de
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
8 changed files with 78 additions and 25 deletions

View file

@ -21,6 +21,7 @@ module Logs.Location (
logStatusAfter,
logChange,
loggedLocations,
loggedPreviousLocations,
loggedLocationsHistorical,
loggedLocationsRef,
parseLoggedLocations,
@ -79,7 +80,13 @@ logChange _ NoUUID _ = noop
{- Returns a list of repository UUIDs that, according to the log, have
- the value of a key. -}
loggedLocations :: Key -> Annex [UUID]
loggedLocations = getLoggedLocations currentLogInfo
loggedLocations = getLoggedLocations presentLogInfo
{- Returns a list of repository UUIDs that the location log indicates
- used to have the vale of a key, but no longer do.
-}
loggedPreviousLocations :: Key -> Annex [UUID]
loggedPreviousLocations = getLoggedLocations notPresentLogInfo
{- Gets the location log on a particular date. -}
loggedLocationsHistorical :: RefDate -> Key -> Annex [UUID]