diff options
author | 2011-08-19 20:05:08 -0400 | |
---|---|---|
committer | 2011-08-19 20:32:18 -0400 | |
commit | 01cd775d9271dfe96917c5557efe93ce0e6f52c4 (patch) | |
tree | 19cdc3d9fa0876903996cab6c248f2bf91b87577 | |
parent | e3ca08fad89d6f3b5951da74a8af3631c5ef9604 (diff) |
Fix broken upgrade from V1 repository. Closes: #638584
Had forgotten to keep several old versions of functions needed during this
upgrade.
-rw-r--r-- | PresenceLog.hs | 4 | ||||
-rw-r--r-- | Upgrade/V1.hs | 33 | ||||
-rw-r--r-- | debian/changelog | 1 |
3 files changed, 30 insertions, 8 deletions
diff --git a/PresenceLog.hs b/PresenceLog.hs index 9c516a8db..ccb75ff5b 100644 --- a/PresenceLog.hs +++ b/PresenceLog.hs @@ -15,10 +15,12 @@ module PresenceLog ( LogStatus(..), addLog, readLog, + parseLog, writeLog, logNow, compactLog, - currentLog + currentLog, + LogLine ) where import Data.Time.Clock.POSIX diff --git a/Upgrade/V1.hs b/Upgrade/V1.hs index c41310880..160d9309f 100644 --- a/Upgrade/V1.hs +++ b/Upgrade/V1.hs @@ -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 diff --git a/debian/changelog b/debian/changelog index 1ace861a4..7d3315103 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 |