diff options
author | Joey Hess <joey@kitenet.net> | 2010-12-13 11:35:00 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-12-13 11:35:00 -0400 |
commit | 0210628263f5a9da4f7ceb6b359108174ac01182 (patch) | |
tree | a4eb2759362ff45f78b5e69c032d4d1fe9475009 /Upgrade.hs | |
parent | 67c5036579a4c4af99711cba45ffffb032262d60 (diff) |
Fix upgrade from 0.03.
Diffstat (limited to 'Upgrade.hs')
-rw-r--r-- | Upgrade.hs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/Upgrade.hs b/Upgrade.hs index d64d5287d..52ecfa07d 100644 --- a/Upgrade.hs +++ b/Upgrade.hs @@ -7,9 +7,12 @@ module Upgrade where +import System.IO.Error (try) import System.Directory import Control.Monad.State (liftIO) +import Control.Monad (filterM) import System.Posix.Files +import System.FilePath import Core import Types @@ -37,7 +40,7 @@ upgradeFrom0 = do -- do the reorganisation of the files let olddir = annexDir g - keys <- getKeysPresent' olddir + keys <- getKeysPresent0' olddir _ <- mapM (\k -> moveAnnex k $ olddir ++ "/" ++ keyFile k) keys -- update the symlinks to the files @@ -61,3 +64,16 @@ upgradeFrom0 = do liftIO $ createSymbolicLink link f Annex.queue "add" ["--"] f fixlinks fs + +getKeysPresent0' :: FilePath -> Annex [Key] +getKeysPresent0' dir = do + contents <- liftIO $ getDirectoryContents dir + files <- liftIO $ filterM present contents + return $ map fileKey files + where + present d = do + result <- try $ + getFileStatus $ dir ++ "/" ++ takeFileName d + case result of + Right s -> return $ isRegularFile s + Left _ -> return False |