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(..),
addLog,
readLog,
parseLog,
writeLog,
logNow,
compactLog,
currentLog
currentLog,
LogLine
) where
import Data.Time.Clock.POSIX

View file

@ -22,7 +22,7 @@ import Types.Key
import Content
import Types
import Locations
import LocationLog
import PresenceLog
import qualified Annex
import qualified AnnexQueue
import qualified Git
@ -123,7 +123,7 @@ moveLocationLogs = do
else return []
move (l, k) = do
g <- Annex.gitRepo
let dest = logFile k
let dest = logFile2 g k
let dir = Upgrade.V2.gitStateDir g
let f = dir </> l
liftIO $ createDirectoryIfMissing True (parentDir dest)
@ -131,9 +131,9 @@ moveLocationLogs = do
-- log files that are not checked into git,
-- as well as merging with already upgraded
-- logs that have been pulled from elsewhere
old <- readLog f
new <- readLog dest
writeLog dest (old++new)
old <- liftIO $ readLog1 f
new <- liftIO $ readLog1 dest
liftIO $ writeLog1 dest (old++new)
AnnexQueue.add "add" [Param "--"] [dest]
AnnexQueue.add "add" [Param "--"] [f]
AnnexQueue.add "rm" [Param "--quiet", Param "-f", Param "--"] [f]
@ -186,8 +186,11 @@ fileKey1 :: FilePath -> Key
fileKey1 file = readKey1 $
replace "&a" "&" $ replace "&s" "%" $ replace "%" "/" file
logFile1 :: Git.Repo -> Key -> String
logFile1 repo key = Upgrade.V2.gitStateDir repo ++ keyFile1 key ++ ".log"
writeLog1 :: FilePath -> [LogLine] -> IO ()
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 file = do
@ -230,3 +233,19 @@ getKeyFilesPresent1' dir = do
case result of
Right s -> return $ isRegularFile s
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.
* Added annex-cost-command configuration, which can be used to vary the
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