diff options
author | Joey Hess <joey@kitenet.net> | 2011-07-01 17:23:01 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-07-01 17:23:01 -0400 |
commit | 79016c197ca87182dfae9f6dfb994ff5079fc952 (patch) | |
tree | 2f96d12413a757529b56ca876e3220bab4dee1e4 /LocationLog.hs | |
parent | fb58d1a560f7c4c94826ec63de16e0276d1f17f8 (diff) |
add hashing to web log files
Diffstat (limited to 'LocationLog.hs')
-rw-r--r-- | LocationLog.hs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/LocationLog.hs b/LocationLog.hs index 19a8eb83a..eb48b7916 100644 --- a/LocationLog.hs +++ b/LocationLog.hs @@ -17,7 +17,9 @@ module LocationLog ( readLog, writeLog, keyLocations, - loggedKeys + loggedKeys, + logFile, + logFileKey ) where import System.FilePath @@ -28,6 +30,7 @@ import qualified Git import qualified Branch import UUID import Types +import Types.Key import Locations import PresenceLog @@ -49,3 +52,15 @@ keyLocations key = currentLog $ logFile key loggedKeys :: Annex [Key] loggedKeys = return . catMaybes . map (logFileKey . takeFileName) =<< Branch.files + +{- The filename of the log file for a given key. -} +logFile :: Key -> String +logFile key = hashDirLower key ++ keyFile key ++ ".log" + +{- Converts a log filename into a key. -} +logFileKey :: FilePath -> Maybe Key +logFileKey file + | end == ".log" = readKey beginning + | otherwise = Nothing + where + (beginning, end) = splitAt (length file - 4) file |