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
|
Left ex -> err $ "Automatic upgrade exception! " ++ show ex
|
||||||
|
|
||||||
upgrade :: Bool -> RepoVersion -> Annex Bool
|
upgrade :: Bool -> RepoVersion -> Annex Bool
|
||||||
upgrade automatic destversion = do
|
upgrade automatic destversion = go =<< getVersion
|
||||||
startversion <- getVersion
|
|
||||||
(ok, newversion) <- go startversion
|
|
||||||
when (ok && newversion /= startversion) $
|
|
||||||
postupgrade newversion
|
|
||||||
return ok
|
|
||||||
where
|
where
|
||||||
go (Just v)
|
go (Just v)
|
||||||
| v >= destversion = return (True, Just v)
|
| v >= destversion = return True
|
||||||
| otherwise = ifM upgradingRemote
|
| otherwise = ifM upgradingRemote
|
||||||
( upgraderemote
|
( upgraderemote
|
||||||
, up v >>= \case
|
, up v >>= \case
|
||||||
UpgradeSuccess -> go (Just (incrversion v) )
|
UpgradeSuccess -> do
|
||||||
UpgradeFailed -> return (False, Just v)
|
let v' = incrversion v
|
||||||
UpgradeDeferred -> return (True, Just 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)
|
incrversion v = RepoVersion (fromRepoVersion v + 1)
|
||||||
|
|
||||||
postupgrade newversion = ifM upgradingRemote
|
|
||||||
( reloadConfig
|
|
||||||
, maybe noop upgradedto newversion
|
|
||||||
)
|
|
||||||
|
|
||||||
#ifndef mingw32_HOST_OS
|
#ifndef mingw32_HOST_OS
|
||||||
up (RepoVersion 0) = Upgrade.V0.upgrade
|
up (RepoVersion 0) = Upgrade.V0.upgrade
|
||||||
up (RepoVersion 1) = Upgrade.V1.upgrade
|
up (RepoVersion 1) = Upgrade.V1.upgrade
|
||||||
|
@ -121,15 +114,18 @@ upgrade automatic destversion = do
|
||||||
-- upgrading a git repo other than the current repo.
|
-- upgrading a git repo other than the current repo.
|
||||||
upgraderemote = do
|
upgraderemote = do
|
||||||
rp <- fromRawFilePath <$> fromRepo Git.repoPath
|
rp <- fromRawFilePath <$> fromRepo Git.repoPath
|
||||||
gitAnnexChildProcess "upgrade"
|
ok <- gitAnnexChildProcess "upgrade"
|
||||||
[ Param "--quiet"
|
[ Param "--quiet"
|
||||||
, Param "--autoonly"
|
, Param "--autoonly"
|
||||||
]
|
]
|
||||||
(\p -> p { cwd = Just rp })
|
(\p -> p { cwd = Just rp })
|
||||||
(\_ _ _ pid -> waitForProcess pid >>= return . \case
|
(\_ _ _ pid -> waitForProcess pid >>= return . \case
|
||||||
ExitSuccess -> (True, Nothing)
|
ExitSuccess -> True
|
||||||
_ -> (False, Nothing)
|
_ -> False
|
||||||
)
|
)
|
||||||
|
when ok
|
||||||
|
reloadConfig
|
||||||
|
return ok
|
||||||
|
|
||||||
upgradedto v = do
|
upgradedto v = do
|
||||||
setVersion v
|
setVersion v
|
||||||
|
|
|
@ -40,12 +40,13 @@ upgrade automatic
|
||||||
- and it is not safe for such to still be running after
|
- and it is not safe for such to still be running after
|
||||||
- this upgrade. -}
|
- this upgrade. -}
|
||||||
oldprocessesdanger = timeOfUpgrade (RepoVersion 9) >>= \case
|
oldprocessesdanger = timeOfUpgrade (RepoVersion 9) >>= \case
|
||||||
Nothing -> pure True
|
|
||||||
Just t -> do
|
Just t -> do
|
||||||
now <- liftIO getPOSIXTime
|
now <- liftIO getPOSIXTime
|
||||||
if now < t + 365*24*60*60
|
if now < t + 365*24*60*60
|
||||||
then return True
|
then return True
|
||||||
else assistantrunning
|
else assistantrunning
|
||||||
|
-- Initialized at v9, so no old process danger exists.
|
||||||
|
Nothing -> pure False
|
||||||
|
|
||||||
{- Skip upgrade when git-annex assistant (or watch) is running,
|
{- Skip upgrade when git-annex assistant (or watch) is running,
|
||||||
- because these are long-running daemons that could conceivably
|
- because these are long-running daemons that could conceivably
|
||||||
|
|
|
@ -16,3 +16,4 @@ git config annex.version
|
||||||
|
|
||||||
10.20220822 Linux
|
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
|
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
|
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.
|
Gonna need to make a git-annex release ASAP to get this fix out there.
|
||||||
"""]]
|
"""]]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue