aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-07-01 17:23:01 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-07-01 17:23:01 -0400
commit79016c197ca87182dfae9f6dfb994ff5079fc952 (patch)
tree2f96d12413a757529b56ca876e3220bab4dee1e4
parentfb58d1a560f7c4c94826ec63de16e0276d1f17f8 (diff)
add hashing to web log files
-rw-r--r--LocationLog.hs17
-rw-r--r--Locations.hs14
-rw-r--r--Remote/Web.hs6
-rw-r--r--Upgrade/V2.hs2
4 files changed, 21 insertions, 18 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
diff --git a/Locations.hs b/Locations.hs
index 6142b2393..347b08ce1 100644
--- a/Locations.hs
+++ b/Locations.hs
@@ -19,8 +19,6 @@ module Locations (
gitAnnexUnusedLog,
gitAnnexJournalDir,
isLinkToAnnex,
- logFile,
- logFileKey,
hashDirMixed,
hashDirLower,
@@ -115,18 +113,6 @@ gitAnnexJournalDir r = addTrailingPathSeparator $ gitAnnexDir r </> "journal"
isLinkToAnnex :: FilePath -> Bool
isLinkToAnnex s = ("/.git/" ++ objectDir) `isInfixOf` s
-{- 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
-
{- Converts a key into a filename fragment.
-
- Escape "/" in the key name, to keep a flat tree of files and avoid
diff --git a/Remote/Web.hs b/Remote/Web.hs
index 342acef91..7425dec87 100644
--- a/Remote/Web.hs
+++ b/Remote/Web.hs
@@ -29,6 +29,7 @@ import UUID
import Config
import PresenceLog
import LocationLog
+import Locations
remote :: RemoteType Annex
remote = RemoteType {
@@ -62,9 +63,10 @@ gen r _ _ =
config = Nothing
}
-{- The urls for a key are stored in remote/web/key.log in the git-annex branch. -}
+{- The urls for a key are stored in remote/web/hash/key.log
+ - in the git-annex branch. -}
urlLog :: Key -> FilePath
-urlLog key = "remote/web" </> show key ++ ".log"
+urlLog key = "remote/web" </> hashDirLower key </> show key ++ ".log"
getUrls :: Key -> Annex [URLString]
getUrls key = currentLog (urlLog key)
diff --git a/Upgrade/V2.hs b/Upgrade/V2.hs
index ce0424b30..14e328edb 100644
--- a/Upgrade/V2.hs
+++ b/Upgrade/V2.hs
@@ -20,7 +20,7 @@ import qualified Git
import qualified Branch
import Messages
import Utility
-import Locations
+import LocationLog
import Content
olddir :: Git.Repo -> FilePath