fixed logFile
This commit is contained in:
parent
e0bd9d43a2
commit
1870186632
11 changed files with 26 additions and 36 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
16
Locations.hs
16
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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue