add timestamps to remote.log
This commit is contained in:
parent
f929d0229c
commit
f011033869
4 changed files with 23 additions and 24 deletions
30
RemoteLog.hs
30
RemoteLog.hs
|
@ -6,7 +6,6 @@
|
||||||
-}
|
-}
|
||||||
|
|
||||||
module RemoteLog (
|
module RemoteLog (
|
||||||
remoteLog,
|
|
||||||
readRemoteLog,
|
readRemoteLog,
|
||||||
configSet,
|
configSet,
|
||||||
keyValToConfig,
|
keyValToConfig,
|
||||||
|
@ -16,12 +15,14 @@ module RemoteLog (
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
import Data.Time.Clock.POSIX
|
||||||
import Data.Char
|
import Data.Char
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
import qualified Annex.Branch
|
import qualified Annex.Branch
|
||||||
import Types.Remote
|
import Types.Remote
|
||||||
import UUID
|
import UUID
|
||||||
|
import UUIDLog
|
||||||
|
|
||||||
{- Filename of remote.log. -}
|
{- Filename of remote.log. -}
|
||||||
remoteLog :: FilePath
|
remoteLog :: FilePath
|
||||||
|
@ -29,27 +30,20 @@ remoteLog = "remote.log"
|
||||||
|
|
||||||
{- Adds or updates a remote's config in the log. -}
|
{- Adds or updates a remote's config in the log. -}
|
||||||
configSet :: UUID -> RemoteConfig -> Annex ()
|
configSet :: UUID -> RemoteConfig -> Annex ()
|
||||||
configSet u c = Annex.Branch.change remoteLog $
|
configSet u c = do
|
||||||
serialize . M.insert u c . remoteLogParse
|
ts <- liftIO $ getPOSIXTime
|
||||||
where
|
Annex.Branch.change remoteLog $
|
||||||
serialize = unlines . sort . map toline . M.toList
|
showLog showConfig . changeLog ts u c . parseLog parseConfig
|
||||||
toline (u', c') = u' ++ " " ++ unwords (configToKeyVal c')
|
|
||||||
|
|
||||||
{- Map of remotes by uuid containing key/value config maps. -}
|
{- Map of remotes by uuid containing key/value config maps. -}
|
||||||
readRemoteLog :: Annex (M.Map UUID RemoteConfig)
|
readRemoteLog :: Annex (M.Map UUID RemoteConfig)
|
||||||
readRemoteLog = remoteLogParse <$> Annex.Branch.get remoteLog
|
readRemoteLog = (simpleMap . parseLog parseConfig) <$> Annex.Branch.get remoteLog
|
||||||
|
|
||||||
remoteLogParse :: String -> M.Map UUID RemoteConfig
|
parseConfig :: String -> Maybe RemoteConfig
|
||||||
remoteLogParse s =
|
parseConfig = Just . keyValToConfig . words
|
||||||
M.fromList $ mapMaybe parseline $ filter (not . null) $ lines s
|
|
||||||
where
|
showConfig :: RemoteConfig -> String
|
||||||
parseline l
|
showConfig = unwords . configToKeyVal
|
||||||
| length w > 2 = Just (u, c)
|
|
||||||
| otherwise = Nothing
|
|
||||||
where
|
|
||||||
w = words l
|
|
||||||
u = head w
|
|
||||||
c = keyValToConfig $ tail w
|
|
||||||
|
|
||||||
{- Given Strings like "key=value", generates a RemoteConfig. -}
|
{- Given Strings like "key=value", generates a RemoteConfig. -}
|
||||||
keyValToConfig :: [String] -> RemoteConfig
|
keyValToConfig :: [String] -> RemoteConfig
|
||||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -12,7 +12,7 @@ git-annex (3.20110929) UNRELEASED; urgency=low
|
||||||
has been merged.
|
has been merged.
|
||||||
* Note that older versions of git-annex will display the timestamp as part
|
* Note that older versions of git-annex will display the timestamp as part
|
||||||
of the repository description, which is ugly but otherwise harmless.
|
of the repository description, which is ugly but otherwise harmless.
|
||||||
* Add timestamps to trust.log.
|
* Add timestamps to trust.log and remote.log too.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Thu, 29 Sep 2011 18:58:53 -0400
|
-- Joey Hess <joeyh@debian.org> Thu, 29 Sep 2011 18:58:53 -0400
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,9 @@ would keep working, ignoring the timestamp.
|
||||||
- remote.log: "uuid key=value ... timestamp" is on the edge but does work
|
- remote.log: "uuid key=value ... timestamp" is on the edge but does work
|
||||||
(old git-annex will include the timestamp in the key/value map it builds,
|
(old git-annex will include the timestamp in the key/value map it builds,
|
||||||
but that should not break anything really)
|
but that should not break anything really)
|
||||||
|
> update: converted! --[[Joey]]
|
||||||
|
|
||||||
Appending "timestamp=xxxxx" would be good for clarity, and make
|
Appending "timestamp=xxxxx" would be good for clarity, and make
|
||||||
it easier to parse the timestamp out from lines that have it.
|
it easier to parse the timestamp out from lines that have it.
|
||||||
|
|
||||||
|
> [[done]] --[[Joey]]
|
||||||
|
|
|
@ -54,7 +54,7 @@ Amazon S3.
|
||||||
|
|
||||||
The file format is one line per remote, starting with the uuid of the
|
The file format is one line per remote, starting with the uuid of the
|
||||||
remote, followed by a space, and then a series of key=value pairs,
|
remote, followed by a space, and then a series of key=value pairs,
|
||||||
each separated by whitespace.
|
each separated by whitespace, and finally a timestamp.
|
||||||
|
|
||||||
## `trust.log`
|
## `trust.log`
|
||||||
|
|
||||||
|
@ -62,13 +62,15 @@ Records the [[trust]] information for repositories. Does not exist unless
|
||||||
[[trust]] values are configured.
|
[[trust]] values are configured.
|
||||||
|
|
||||||
The file format is one line per repository, with the uuid followed by a
|
The file format is one line per repository, with the uuid followed by a
|
||||||
space, and then either 1 (trusted), 0 (untrusted), or ? (semi-trusted).
|
space, and then either 1 (trusted), 0 (untrusted), or ? (semi-trusted),
|
||||||
Repositories not listed are semi-trusted.
|
and finally a timestamp.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
e605dca6-446a-11e0-8b2a-002170d25c55 1
|
e605dca6-446a-11e0-8b2a-002170d25c55 1 timestamp=1317929189.157237s
|
||||||
26339d22-446b-11e0-9101-002170d25c55 ?
|
26339d22-446b-11e0-9101-002170d25c55 ? timestamp=1317929330.769997s
|
||||||
|
|
||||||
|
Repositories not listed are semi-trusted.
|
||||||
|
|
||||||
## `aaa/bbb/*.log`
|
## `aaa/bbb/*.log`
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue