diff options
-rw-r--r-- | Backend/File.hs | 5 | ||||
-rw-r--r-- | Command/Fsck.hs | 2 | ||||
-rw-r--r-- | Command/Init.hs | 4 | ||||
-rw-r--r-- | Command/Unused.hs | 3 | ||||
-rw-r--r-- | Command/Whereis.hs | 4 | ||||
-rw-r--r-- | Content.hs | 1 | ||||
-rw-r--r-- | LocationLog.hs | 13 | ||||
-rw-r--r-- | Locations.hs | 16 | ||||
-rw-r--r-- | Remote.hs | 2 | ||||
-rw-r--r-- | Upgrade/V1.hs | 2 | ||||
-rw-r--r-- | Upgrade/V2.hs | 10 |
11 files changed, 26 insertions, 36 deletions
diff --git a/Backend/File.hs b/Backend/File.hs index 20cb3e95a..eab987ef8 100644 --- a/Backend/File.hs +++ b/Backend/File.hs @@ -131,7 +131,7 @@ showLocations :: Key -> [UUID] -> Annex () showLocations key exclude = do g <- Annex.gitRepo u <- getUUID g - uuids <- keyLocations g key + uuids <- keyLocations key untrusteduuids <- trustGet UnTrusted let uuidswanted = filteruuids uuids (u:exclude++untrusteduuids) let uuidsskipped = filteruuids uuids (u:exclude++uuidswanted) @@ -188,8 +188,7 @@ checkKeyOnly = checkKey (\_ -> return True) checkKeyNumCopies :: Key -> Maybe FilePath -> Maybe Int -> Annex Bool checkKeyNumCopies key file numcopies = do needed <- getNumCopies numcopies - g <- Annex.gitRepo - locations <- keyLocations g key + locations <- keyLocations key untrusted <- trustGet UnTrusted let untrustedlocations = intersect untrusted locations let safelocations = filter (`notElem` untrusted) locations diff --git a/Command/Fsck.hs b/Command/Fsck.hs index 7c840d528..0e3df03dd 100644 --- a/Command/Fsck.hs +++ b/Command/Fsck.hs @@ -60,7 +60,7 @@ verifyLocationLog key file = do preventWrite (parentDir f) u <- getUUID g - uuids <- keyLocations g key + uuids <- keyLocations key case (present, u `elem` uuids) of (True, False) -> do diff --git a/Command/Init.hs b/Command/Init.hs index 1e1eb527a..dbf5666cd 100644 --- a/Command/Init.hs +++ b/Command/Init.hs @@ -8,9 +8,8 @@ module Command.Init where import Control.Monad.State (liftIO) -import Control.Monad (when, unless) +import Control.Monad (when) import System.Directory -import System.FilePath import Command import qualified Annex @@ -19,7 +18,6 @@ import qualified Branch import UUID import Version import Messages -import Locations import Types import Utility diff --git a/Command/Unused.hs b/Command/Unused.hs index 4389b2209..5d4e433ad 100644 --- a/Command/Unused.hs +++ b/Command/Unused.hs @@ -78,8 +78,7 @@ checkRemoteUnused' r = do showLongNote $ "\n" where isthere k = do - g <- Annex.gitRepo - us <- keyLocations g k + us <- keyLocations k return $ uuid `elem` us uuid = Remote.uuid r diff --git a/Command/Whereis.hs b/Command/Whereis.hs index bcd4a2e22..3a7213217 100644 --- a/Command/Whereis.hs +++ b/Command/Whereis.hs @@ -7,7 +7,6 @@ module Command.Whereis where -import qualified Annex import LocationLog import Command import Messages @@ -28,8 +27,7 @@ start file = isAnnexed file $ \(key, _) -> do perform :: Key -> CommandPerform perform key = do - g <- Annex.gitRepo - uuids <- keyLocations g key + uuids <- keyLocations key let num = length uuids showNote $ show num ++ " " ++ copiesplural num if null $ uuids diff --git a/Content.hs b/Content.hs index fc8ebeb21..5d77cc979 100644 --- a/Content.hs +++ b/Content.hs @@ -38,7 +38,6 @@ import LocationLog import UUID import qualified GitRepo as Git import qualified Annex -import qualified AnnexQueue import Utility import StatFS import Types.Key diff --git a/LocationLog.hs b/LocationLog.hs index 68a1eb790..8dbeb729c 100644 --- a/LocationLog.hs +++ b/LocationLog.hs @@ -20,8 +20,7 @@ module LocationLog ( readLog, writeLog, keyLocations, - loggedKeys, - logFile + loggedKeys ) where import Data.Time.Clock.POSIX @@ -89,7 +88,7 @@ logChange repo key u s = do error $ "unknown UUID for " ++ Git.repoDescribe repo ++ " (have you run git annex init there?)" line <- logNow s u - let f = logFile repo key + let f = logFile key ls <- readLog f writeLog f (compactLog $ line:ls) @@ -116,9 +115,9 @@ logNow s u = do {- Returns a list of repository UUIDs that, according to the log, have - the value of a key. -} -keyLocations :: Git.Repo -> Key -> Annex [UUID] -keyLocations thisrepo key = do - ls <- readLog $ logFile thisrepo key +keyLocations :: Key -> Annex [UUID] +keyLocations key = do + ls <- readLog $ logFile key return $ map uuid $ filterPresent ls {- Filters the list of LogLines to find ones where the value @@ -151,7 +150,7 @@ mapLog m l = - (There may be duplicate keys in the list.) -} loggedKeys :: Git.Repo -> Annex [Key] loggedKeys repo = do - error "FIXME.. does not look in git-annex branch yet" + _ <- error "FIXME.. does not look in git-annex branch yet" exists <- liftIO $ doesDirectoryExist dir if exists then do diff --git a/Locations.hs b/Locations.hs index 8f7b11a5c..d2241636e 100644 --- a/Locations.hs +++ b/Locations.hs @@ -21,7 +21,6 @@ module Locations ( gitAnnexUnusedLog, isLinkToAnnex, logFile, - logFileOld, logFileKey, hashDirMixed, @@ -119,19 +118,8 @@ isLinkToAnnex :: FilePath -> Bool isLinkToAnnex s = ("/.git/" ++ objectDir) `isInfixOf` s {- The filename of the log file for a given key. -} -logFile :: Git.Repo -> Key -> String -logFile = logFile' hashDirLower - -{- The old filename of the log file for a key. These can have mixed - - case, which turned out to be a bad idea for directories whose contents - - are checked into git. There was no conversion, so these have to be checked - - for and merged in at runtime. -} -logFileOld :: Git.Repo -> Key -> String -logFileOld = logFile' hashDirMixed - -logFile' :: (Key -> FilePath) -> Git.Repo -> Key -> String -logFile' hasher repo key = - gitStateDir repo ++ hasher key ++ keyFile key ++ ".log" +logFile :: Key -> String +logFile key = hashDirLower key ++ keyFile key ++ ".log" {- Converts a log filename into a key. -} logFileKey :: FilePath -> Maybe Key @@ -141,7 +141,7 @@ keyPossibilities key = do trusted <- trustGet Trusted -- get uuids of all remotes that are recorded to have the key - uuids <- keyLocations g key + uuids <- keyLocations key let validuuids = filter (/= u) uuids -- note that validuuids is assumed to not have dups diff --git a/Upgrade/V1.hs b/Upgrade/V1.hs index b139e2820..1f327f77b 100644 --- a/Upgrade/V1.hs +++ b/Upgrade/V1.hs @@ -121,7 +121,7 @@ moveLocationLogs = do else return [] move (l, k) = do g <- Annex.gitRepo - let dest = logFile g k + let dest = logFile k let dir = gitStateDir g let f = dir </> l liftIO $ createDirectoryIfMissing True (parentDir dest) diff --git a/Upgrade/V2.hs b/Upgrade/V2.hs index deb231d52..03ef7ba69 100644 --- a/Upgrade/V2.hs +++ b/Upgrade/V2.hs @@ -46,3 +46,13 @@ gitAttributesUnWrite repo = do c <- readFileStrict attributes safeWriteFile attributes $ unlines $ filter (\l -> not $ l `elem` attrLines) $ lines c + +oldlogFile :: Git.Repo -> Key -> String +oldlogFile = logFile' hashDirLower + +oldlogFileOld :: Git.Repo -> Key -> String +oldlogFileOld = logFile' hashDirMixed + +logFile' :: (Key -> FilePath) -> Git.Repo -> Key -> String +logFile' hasher repo key = + gitStateDir repo ++ hasher key ++ keyFile key ++ ".log" |