summaryrefslogtreecommitdiff
path: root/LocationLog.hs
diff options
context:
space:
mode:
Diffstat (limited to 'LocationLog.hs')
-rw-r--r--LocationLog.hs17
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