summaryrefslogtreecommitdiff
path: root/LocationLog.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-04-02 13:49:03 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-04-02 13:49:03 -0400
commit616e6f8a840ef4d99632d12a2e7ea15c3cfb1805 (patch)
treec42b38debbc74df5d989562c515c3da1b9ae44e4 /LocationLog.hs
parent66ab18325e93b244b27b1c80269c943388622716 (diff)
Use lowercase hash directories for locationlog files
to avoid some issues with git on OSX with the mixed-case directories. No migration is needed; the old mixed case hash directories are still read; new information is written to the new directories.
Diffstat (limited to 'LocationLog.hs')
-rw-r--r--LocationLog.hs23
1 files changed, 8 insertions, 15 deletions
diff --git a/LocationLog.hs b/LocationLog.hs
index d989cad61..8a47db2da 100644
--- a/LocationLog.hs
+++ b/LocationLog.hs
@@ -23,7 +23,6 @@
module LocationLog (
LogStatus(..),
logChange,
- logFile,
readLog,
writeLog,
keyLocations
@@ -33,7 +32,6 @@ import Data.Time.Clock.POSIX
import Data.Time
import System.Locale
import qualified Data.Map as Map
-import System.Directory
import Control.Monad (when)
import qualified GitRepo as Git
@@ -93,22 +91,16 @@ logChange repo key u s = do
error $ "unknown UUID for " ++ Git.repoDescribe repo ++
" (have you run git annex init there?)"
line <- logNow s u
- ls <- readLog logfile
- writeLog logfile (compactLog $ line:ls)
- return logfile
- where
- logfile = logFile repo key
+ let f = logFile repo key
+ ls' <- readLog $ logFileOld repo key
+ ls <- readLog f
+ writeLog f (compactLog $ line:ls'++ls)
+ return f
{- Reads a log file.
- Note that the LogLines returned may be in any order. -}
readLog :: FilePath -> IO [LogLine]
-readLog file = do
- exists <- doesFileExist file
- if exists
- then do
- s <- readFile file
- return $ parseLog s
- else return []
+readLog file = catch (return . parseLog =<< readFile file) (const $ return [])
parseLog :: String -> [LogLine]
parseLog s = filter parsable $ map read $ lines s
@@ -131,7 +123,8 @@ logNow s u = do
keyLocations :: Git.Repo -> Key -> IO [UUID]
keyLocations thisrepo key = do
ls <- readLog $ logFile thisrepo key
- return $ map uuid $ filterPresent ls
+ ls' <- readLog $ logFileOld thisrepo key
+ return $ map uuid $ filterPresent $ ls'++ls
{- Filters the list of LogLines to find ones where the value
- is (or should still be) present. -}