handle upgrading repositories initialized with --version=9
As was attempted earlier in the buggy commit 0d2e3058ee
Avoided the bug that had by making the upgrade log be updated after each
upgrade step. So, after upgrade from v8 to v9, the log is updated, and
so Upgrade.V9's timeOfUpgrade check will find that it was upgraded
recently and so won't let it skip ahead to v10.
Sponsored-by: k0ld on Patreon
This commit is contained in:
parent
8230f4a6f1
commit
e05dd70544
4 changed files with 19 additions and 21 deletions
34
Upgrade.hs
34
Upgrade.hs
|
@ -74,31 +74,24 @@ needsUpgrade v
|
|||
Left ex -> err $ "Automatic upgrade exception! " ++ show ex
|
||||
|
||||
upgrade :: Bool -> RepoVersion -> Annex Bool
|
||||
upgrade automatic destversion = do
|
||||
startversion <- getVersion
|
||||
(ok, newversion) <- go startversion
|
||||
when (ok && newversion /= startversion) $
|
||||
postupgrade newversion
|
||||
return ok
|
||||
upgrade automatic destversion = go =<< getVersion
|
||||
where
|
||||
go (Just v)
|
||||
| v >= destversion = return (True, Just v)
|
||||
| v >= destversion = return True
|
||||
| otherwise = ifM upgradingRemote
|
||||
( upgraderemote
|
||||
, up v >>= \case
|
||||
UpgradeSuccess -> go (Just (incrversion v) )
|
||||
UpgradeFailed -> return (False, Just v)
|
||||
UpgradeDeferred -> return (True, Just v)
|
||||
UpgradeSuccess -> do
|
||||
let v' = incrversion v
|
||||
upgradedto v'
|
||||
go (Just v')
|
||||
UpgradeFailed -> return False
|
||||
UpgradeDeferred -> return True
|
||||
)
|
||||
go Nothing = return (True, Nothing)
|
||||
go Nothing = return True
|
||||
|
||||
incrversion v = RepoVersion (fromRepoVersion v + 1)
|
||||
|
||||
postupgrade newversion = ifM upgradingRemote
|
||||
( reloadConfig
|
||||
, maybe noop upgradedto newversion
|
||||
)
|
||||
|
||||
#ifndef mingw32_HOST_OS
|
||||
up (RepoVersion 0) = Upgrade.V0.upgrade
|
||||
up (RepoVersion 1) = Upgrade.V1.upgrade
|
||||
|
@ -121,15 +114,18 @@ upgrade automatic destversion = do
|
|||
-- upgrading a git repo other than the current repo.
|
||||
upgraderemote = do
|
||||
rp <- fromRawFilePath <$> fromRepo Git.repoPath
|
||||
gitAnnexChildProcess "upgrade"
|
||||
ok <- gitAnnexChildProcess "upgrade"
|
||||
[ Param "--quiet"
|
||||
, Param "--autoonly"
|
||||
]
|
||||
(\p -> p { cwd = Just rp })
|
||||
(\_ _ _ pid -> waitForProcess pid >>= return . \case
|
||||
ExitSuccess -> (True, Nothing)
|
||||
_ -> (False, Nothing)
|
||||
ExitSuccess -> True
|
||||
_ -> False
|
||||
)
|
||||
when ok
|
||||
reloadConfig
|
||||
return ok
|
||||
|
||||
upgradedto v = do
|
||||
setVersion v
|
||||
|
|
|
@ -40,12 +40,13 @@ upgrade automatic
|
|||
- and it is not safe for such to still be running after
|
||||
- this upgrade. -}
|
||||
oldprocessesdanger = timeOfUpgrade (RepoVersion 9) >>= \case
|
||||
Nothing -> pure True
|
||||
Just t -> do
|
||||
now <- liftIO getPOSIXTime
|
||||
if now < t + 365*24*60*60
|
||||
then return True
|
||||
else assistantrunning
|
||||
-- Initialized at v9, so no old process danger exists.
|
||||
Nothing -> pure False
|
||||
|
||||
{- Skip upgrade when git-annex assistant (or watch) is running,
|
||||
- because these are long-running daemons that could conceivably
|
||||
|
|
|
@ -16,3 +16,4 @@ git config annex.version
|
|||
|
||||
10.20220822 Linux
|
||||
|
||||
> [[fixed|done]] --[[Joey]]
|
||||
|
|
|
@ -8,7 +8,7 @@ which was included in version 10.20220822.
|
|||
|
||||
I've reverted the commit as a first step. This means repos initialized
|
||||
at v9 will never autoupgrade to v10, which will need to be fixed
|
||||
somehow.
|
||||
somehow. (Update: Fixed that now.)
|
||||
|
||||
Gonna need to make a git-annex release ASAP to get this fix out there.
|
||||
"""]]
|
||||
|
|
Loading…
Reference in a new issue