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
|
showLocations key exclude = do
|
||||||
g <- Annex.gitRepo
|
g <- Annex.gitRepo
|
||||||
u <- getUUID g
|
u <- getUUID g
|
||||||
uuids <- keyLocations g key
|
uuids <- keyLocations key
|
||||||
untrusteduuids <- trustGet UnTrusted
|
untrusteduuids <- trustGet UnTrusted
|
||||||
let uuidswanted = filteruuids uuids (u:exclude++untrusteduuids)
|
let uuidswanted = filteruuids uuids (u:exclude++untrusteduuids)
|
||||||
let uuidsskipped = filteruuids uuids (u:exclude++uuidswanted)
|
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 -> Maybe FilePath -> Maybe Int -> Annex Bool
|
||||||
checkKeyNumCopies key file numcopies = do
|
checkKeyNumCopies key file numcopies = do
|
||||||
needed <- getNumCopies numcopies
|
needed <- getNumCopies numcopies
|
||||||
g <- Annex.gitRepo
|
locations <- keyLocations key
|
||||||
locations <- keyLocations g key
|
|
||||||
untrusted <- trustGet UnTrusted
|
untrusted <- trustGet UnTrusted
|
||||||
let untrustedlocations = intersect untrusted locations
|
let untrustedlocations = intersect untrusted locations
|
||||||
let safelocations = filter (`notElem` untrusted) locations
|
let safelocations = filter (`notElem` untrusted) locations
|
||||||
|
|
|
@ -60,7 +60,7 @@ verifyLocationLog key file = do
|
||||||
preventWrite (parentDir f)
|
preventWrite (parentDir f)
|
||||||
|
|
||||||
u <- getUUID g
|
u <- getUUID g
|
||||||
uuids <- keyLocations g key
|
uuids <- keyLocations key
|
||||||
|
|
||||||
case (present, u `elem` uuids) of
|
case (present, u `elem` uuids) of
|
||||||
(True, False) -> do
|
(True, False) -> do
|
||||||
|
|
|
@ -8,9 +8,8 @@
|
||||||
module Command.Init where
|
module Command.Init where
|
||||||
|
|
||||||
import Control.Monad.State (liftIO)
|
import Control.Monad.State (liftIO)
|
||||||
import Control.Monad (when, unless)
|
import Control.Monad (when)
|
||||||
import System.Directory
|
import System.Directory
|
||||||
import System.FilePath
|
|
||||||
|
|
||||||
import Command
|
import Command
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
|
@ -19,7 +18,6 @@ import qualified Branch
|
||||||
import UUID
|
import UUID
|
||||||
import Version
|
import Version
|
||||||
import Messages
|
import Messages
|
||||||
import Locations
|
|
||||||
import Types
|
import Types
|
||||||
import Utility
|
import Utility
|
||||||
|
|
||||||
|
|
|
@ -78,8 +78,7 @@ checkRemoteUnused' r = do
|
||||||
showLongNote $ "\n"
|
showLongNote $ "\n"
|
||||||
where
|
where
|
||||||
isthere k = do
|
isthere k = do
|
||||||
g <- Annex.gitRepo
|
us <- keyLocations k
|
||||||
us <- keyLocations g k
|
|
||||||
return $ uuid `elem` us
|
return $ uuid `elem` us
|
||||||
uuid = Remote.uuid r
|
uuid = Remote.uuid r
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
module Command.Whereis where
|
module Command.Whereis where
|
||||||
|
|
||||||
import qualified Annex
|
|
||||||
import LocationLog
|
import LocationLog
|
||||||
import Command
|
import Command
|
||||||
import Messages
|
import Messages
|
||||||
|
@ -28,8 +27,7 @@ start file = isAnnexed file $ \(key, _) -> do
|
||||||
|
|
||||||
perform :: Key -> CommandPerform
|
perform :: Key -> CommandPerform
|
||||||
perform key = do
|
perform key = do
|
||||||
g <- Annex.gitRepo
|
uuids <- keyLocations key
|
||||||
uuids <- keyLocations g key
|
|
||||||
let num = length uuids
|
let num = length uuids
|
||||||
showNote $ show num ++ " " ++ copiesplural num
|
showNote $ show num ++ " " ++ copiesplural num
|
||||||
if null $ uuids
|
if null $ uuids
|
||||||
|
|
|
@ -38,7 +38,6 @@ import LocationLog
|
||||||
import UUID
|
import UUID
|
||||||
import qualified GitRepo as Git
|
import qualified GitRepo as Git
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
import qualified AnnexQueue
|
|
||||||
import Utility
|
import Utility
|
||||||
import StatFS
|
import StatFS
|
||||||
import Types.Key
|
import Types.Key
|
||||||
|
|
|
@ -20,8 +20,7 @@ module LocationLog (
|
||||||
readLog,
|
readLog,
|
||||||
writeLog,
|
writeLog,
|
||||||
keyLocations,
|
keyLocations,
|
||||||
loggedKeys,
|
loggedKeys
|
||||||
logFile
|
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Data.Time.Clock.POSIX
|
import Data.Time.Clock.POSIX
|
||||||
|
@ -89,7 +88,7 @@ logChange repo key u s = do
|
||||||
error $ "unknown UUID for " ++ Git.repoDescribe repo ++
|
error $ "unknown UUID for " ++ Git.repoDescribe repo ++
|
||||||
" (have you run git annex init there?)"
|
" (have you run git annex init there?)"
|
||||||
line <- logNow s u
|
line <- logNow s u
|
||||||
let f = logFile repo key
|
let f = logFile key
|
||||||
ls <- readLog f
|
ls <- readLog f
|
||||||
writeLog f (compactLog $ line:ls)
|
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
|
{- Returns a list of repository UUIDs that, according to the log, have
|
||||||
- the value of a key. -}
|
- the value of a key. -}
|
||||||
keyLocations :: Git.Repo -> Key -> Annex [UUID]
|
keyLocations :: Key -> Annex [UUID]
|
||||||
keyLocations thisrepo key = do
|
keyLocations key = do
|
||||||
ls <- readLog $ logFile thisrepo key
|
ls <- readLog $ logFile key
|
||||||
return $ map uuid $ filterPresent ls
|
return $ map uuid $ filterPresent ls
|
||||||
|
|
||||||
{- Filters the list of LogLines to find ones where the value
|
{- 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.) -}
|
- (There may be duplicate keys in the list.) -}
|
||||||
loggedKeys :: Git.Repo -> Annex [Key]
|
loggedKeys :: Git.Repo -> Annex [Key]
|
||||||
loggedKeys repo = do
|
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
|
exists <- liftIO $ doesDirectoryExist dir
|
||||||
if exists
|
if exists
|
||||||
then do
|
then do
|
||||||
|
|
16
Locations.hs
16
Locations.hs
|
@ -21,7 +21,6 @@ module Locations (
|
||||||
gitAnnexUnusedLog,
|
gitAnnexUnusedLog,
|
||||||
isLinkToAnnex,
|
isLinkToAnnex,
|
||||||
logFile,
|
logFile,
|
||||||
logFileOld,
|
|
||||||
logFileKey,
|
logFileKey,
|
||||||
hashDirMixed,
|
hashDirMixed,
|
||||||
|
|
||||||
|
@ -119,19 +118,8 @@ isLinkToAnnex :: FilePath -> Bool
|
||||||
isLinkToAnnex s = ("/.git/" ++ objectDir) `isInfixOf` s
|
isLinkToAnnex s = ("/.git/" ++ objectDir) `isInfixOf` s
|
||||||
|
|
||||||
{- The filename of the log file for a given key. -}
|
{- The filename of the log file for a given key. -}
|
||||||
logFile :: Git.Repo -> Key -> String
|
logFile :: Key -> String
|
||||||
logFile = logFile' hashDirLower
|
logFile key = hashDirLower key ++ keyFile key ++ ".log"
|
||||||
|
|
||||||
{- 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"
|
|
||||||
|
|
||||||
{- Converts a log filename into a key. -}
|
{- Converts a log filename into a key. -}
|
||||||
logFileKey :: FilePath -> Maybe Key
|
logFileKey :: FilePath -> Maybe Key
|
||||||
|
|
|
@ -141,7 +141,7 @@ keyPossibilities key = do
|
||||||
trusted <- trustGet Trusted
|
trusted <- trustGet Trusted
|
||||||
|
|
||||||
-- get uuids of all remotes that are recorded to have the key
|
-- get uuids of all remotes that are recorded to have the key
|
||||||
uuids <- keyLocations g key
|
uuids <- keyLocations key
|
||||||
let validuuids = filter (/= u) uuids
|
let validuuids = filter (/= u) uuids
|
||||||
|
|
||||||
-- note that validuuids is assumed to not have dups
|
-- note that validuuids is assumed to not have dups
|
||||||
|
|
|
@ -121,7 +121,7 @@ moveLocationLogs = do
|
||||||
else return []
|
else return []
|
||||||
move (l, k) = do
|
move (l, k) = do
|
||||||
g <- Annex.gitRepo
|
g <- Annex.gitRepo
|
||||||
let dest = logFile g k
|
let dest = logFile k
|
||||||
let dir = gitStateDir g
|
let dir = gitStateDir g
|
||||||
let f = dir </> l
|
let f = dir </> l
|
||||||
liftIO $ createDirectoryIfMissing True (parentDir dest)
|
liftIO $ createDirectoryIfMissing True (parentDir dest)
|
||||||
|
|
|
@ -46,3 +46,13 @@ gitAttributesUnWrite repo = do
|
||||||
c <- readFileStrict attributes
|
c <- readFileStrict attributes
|
||||||
safeWriteFile attributes $ unlines $
|
safeWriteFile attributes $ unlines $
|
||||||
filter (\l -> not $ l `elem` attrLines) $ lines c
|
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