summaryrefslogtreecommitdiff
path: root/Upgrade/V1.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-03-16 10:56:59 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-03-16 11:00:18 -0400
commita0807999001017bd6897bad82e747c16e18af6bc (patch)
tree514691d628a924814c222c08c7a04e24d0dd815c /Upgrade/V1.hs
parent137257ded1acb1b15c0413a8998af1e999cd1a53 (diff)
upgrades seem to fully work
Diffstat (limited to 'Upgrade/V1.hs')
-rw-r--r--Upgrade/V1.hs34
1 files changed, 32 insertions, 2 deletions
diff --git a/Upgrade/V1.hs b/Upgrade/V1.hs
index 850080436..602ba41c5 100644
--- a/Upgrade/V1.hs
+++ b/Upgrade/V1.hs
@@ -14,9 +14,10 @@ import Control.Monad (filterM, forM_, unless)
import System.Posix.Files
import System.FilePath
import Data.String.Utils
-import Key
import System.Posix.Types
+import Data.Maybe
+import Key
import Content
import Types
import Locations
@@ -94,7 +95,36 @@ updateSymlinks = do
moveLocationLogs :: Annex ()
moveLocationLogs = do
- warning "TODO location log move"
+ logkeys <- oldlocationlogs
+ forM_ logkeys move
+ where
+ oldlocationlogs = do
+ g <- Annex.gitRepo
+ let dir = gitStateDir g
+ contents <- liftIO $ getDirectoryContents dir
+ return $ catMaybes $ map oldlog2key contents
+ move (l, k) = do
+ g <- Annex.gitRepo
+ let dest = logFile g k
+ let dir = gitStateDir g
+ let f = dir </> l
+ liftIO $ createDirectoryIfMissing True (parentDir dest)
+ -- could just git mv, but this way deals with
+ -- log files that are not checked into git
+ liftIO $ copyFile f dest
+ Annex.queue "add" [Param "--"] dest
+ Annex.queue "add" [Param "--"] f
+ Annex.queue "rm" [Param "--quiet", Param "-f", Param "--"] f
+
+oldlog2key :: FilePath -> Maybe (FilePath, Key)
+oldlog2key l =
+ let len = length l - 4 in
+ if drop len l == ".log"
+ then let k = readKey1 (take len l) in
+ if null (keyName k) || null (keyBackendName k)
+ then Nothing
+ else Just (l, k)
+ else Nothing
-- WORM backend keys: "WORM:mtime:size:filename"
-- all the rest: "backend:key"