Fix broken upgrade from V1 repository. Closes: #638584

Had forgotten to keep several old versions of functions needed during this
upgrade.
This commit is contained in:
Joey Hess 2011-08-19 20:05:08 -04:00
parent e3ca08fad8
commit 01cd775d92
3 changed files with 30 additions and 8 deletions

View file

@ -15,10 +15,12 @@ module PresenceLog (
LogStatus(..), LogStatus(..),
addLog, addLog,
readLog, readLog,
parseLog,
writeLog, writeLog,
logNow, logNow,
compactLog, compactLog,
currentLog currentLog,
LogLine
) where ) where
import Data.Time.Clock.POSIX import Data.Time.Clock.POSIX

View file

@ -22,7 +22,7 @@ import Types.Key
import Content import Content
import Types import Types
import Locations import Locations
import LocationLog import PresenceLog
import qualified Annex import qualified Annex
import qualified AnnexQueue import qualified AnnexQueue
import qualified Git import qualified Git
@ -123,7 +123,7 @@ moveLocationLogs = do
else return [] else return []
move (l, k) = do move (l, k) = do
g <- Annex.gitRepo g <- Annex.gitRepo
let dest = logFile k let dest = logFile2 g k
let dir = Upgrade.V2.gitStateDir g let dir = Upgrade.V2.gitStateDir g
let f = dir </> l let f = dir </> l
liftIO $ createDirectoryIfMissing True (parentDir dest) liftIO $ createDirectoryIfMissing True (parentDir dest)
@ -131,9 +131,9 @@ moveLocationLogs = do
-- log files that are not checked into git, -- log files that are not checked into git,
-- as well as merging with already upgraded -- as well as merging with already upgraded
-- logs that have been pulled from elsewhere -- logs that have been pulled from elsewhere
old <- readLog f old <- liftIO $ readLog1 f
new <- readLog dest new <- liftIO $ readLog1 dest
writeLog dest (old++new) liftIO $ writeLog1 dest (old++new)
AnnexQueue.add "add" [Param "--"] [dest] AnnexQueue.add "add" [Param "--"] [dest]
AnnexQueue.add "add" [Param "--"] [f] AnnexQueue.add "add" [Param "--"] [f]
AnnexQueue.add "rm" [Param "--quiet", Param "-f", Param "--"] [f] AnnexQueue.add "rm" [Param "--quiet", Param "-f", Param "--"] [f]
@ -186,8 +186,11 @@ fileKey1 :: FilePath -> Key
fileKey1 file = readKey1 $ fileKey1 file = readKey1 $
replace "&a" "&" $ replace "&s" "%" $ replace "%" "/" file replace "&a" "&" $ replace "&s" "%" $ replace "%" "/" file
logFile1 :: Git.Repo -> Key -> String writeLog1 :: FilePath -> [LogLine] -> IO ()
logFile1 repo key = Upgrade.V2.gitStateDir repo ++ keyFile1 key ++ ".log" writeLog1 file ls = viaTmp writeFile file (unlines $ map show ls)
readLog1 :: FilePath -> IO [LogLine]
readLog1 file = catch (return . parseLog =<< readFileStrict file) (const $ return [])
lookupFile1 :: FilePath -> Annex (Maybe (Key, Backend Annex)) lookupFile1 :: FilePath -> Annex (Maybe (Key, Backend Annex))
lookupFile1 file = do lookupFile1 file = do
@ -230,3 +233,19 @@ getKeyFilesPresent1' dir = do
case result of case result of
Right s -> return $ isRegularFile s Right s -> return $ isRegularFile s
Left _ -> return False Left _ -> return False
logFile1 :: Git.Repo -> Key -> String
logFile1 repo key = Upgrade.V2.gitStateDir repo ++ keyFile1 key ++ ".log"
logFile2 :: Git.Repo -> Key -> String
logFile2 = logFile' hashDirLower
logFile' :: (Key -> FilePath) -> Git.Repo -> Key -> String
logFile' hasher repo key =
gitStateDir repo ++ hasher key ++ keyFile key ++ ".log"
stateDir :: FilePath
stateDir = addTrailingPathSeparator $ ".git-annex"
gitStateDir :: Git.Repo -> FilePath
gitStateDir repo = addTrailingPathSeparator $ Git.workTree repo </> stateDir

1
debian/changelog vendored
View file

@ -6,6 +6,7 @@ git-annex (3.20110818) UNRELEASED; urgency=low
still recommended to run "git annex init" in any clones, to describe them. still recommended to run "git annex init" in any clones, to describe them.
* Added annex-cost-command configuration, which can be used to vary the * Added annex-cost-command configuration, which can be used to vary the
cost of a remote based on the output of a shell command. cost of a remote based on the output of a shell command.
* Fix broken upgrade from V1 repository. Closes: #638584
-- Joey Hess <joeyh@debian.org> Wed, 17 Aug 2011 13:44:44 -0400 -- Joey Hess <joeyh@debian.org> Wed, 17 Aug 2011 13:44:44 -0400