2014-01-20 20:47:56 +00:00
|
|
|
{- git-annex single-value log
|
|
|
|
-
|
|
|
|
- This is used to store a value in a way that can be union merged.
|
|
|
|
-
|
|
|
|
- A line of the log will look like: "timestamp value"
|
|
|
|
-
|
|
|
|
- The line with the newest timestamp wins.
|
|
|
|
-
|
2015-01-21 16:50:09 +00:00
|
|
|
- Copyright 2014 Joey Hess <id@joeyh.name>
|
2014-01-20 20:47:56 +00:00
|
|
|
-
|
2019-03-13 19:48:14 +00:00
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
2014-01-20 20:47:56 +00:00
|
|
|
-}
|
|
|
|
|
2018-09-05 17:20:10 +00:00
|
|
|
module Logs.SingleValue (
|
|
|
|
module Logs.SingleValue.Pure,
|
|
|
|
readLog,
|
|
|
|
getLog,
|
|
|
|
setLog,
|
|
|
|
) where
|
2014-01-20 20:47:56 +00:00
|
|
|
|
2016-01-20 20:36:33 +00:00
|
|
|
import Annex.Common
|
2014-01-20 20:47:56 +00:00
|
|
|
import qualified Annex.Branch
|
2018-09-05 17:20:10 +00:00
|
|
|
import Logs.SingleValue.Pure
|
2017-08-14 17:55:38 +00:00
|
|
|
import Annex.VectorClock
|
2014-01-20 20:47:56 +00:00
|
|
|
|
|
|
|
import qualified Data.Set as S
|
|
|
|
|
2019-11-26 19:27:22 +00:00
|
|
|
readLog :: (Ord v, SingleValueSerializable v) => RawFilePath -> Annex (Log v)
|
2019-01-07 19:51:05 +00:00
|
|
|
readLog = parseLog <$$> Annex.Branch.get
|
2014-01-20 20:47:56 +00:00
|
|
|
|
2019-11-26 19:27:22 +00:00
|
|
|
getLog :: (Ord v, SingleValueSerializable v) => RawFilePath -> Annex (Maybe v)
|
2014-01-20 20:47:56 +00:00
|
|
|
getLog = newestValue <$$> readLog
|
|
|
|
|
2019-11-26 19:27:22 +00:00
|
|
|
setLog :: (SingleValueSerializable v) => RawFilePath -> v -> Annex ()
|
2014-01-20 20:47:56 +00:00
|
|
|
setLog f v = do
|
2017-08-14 17:55:38 +00:00
|
|
|
c <- liftIO currentVectorClock
|
|
|
|
let ent = LogEntry c v
|
2019-01-07 19:51:05 +00:00
|
|
|
Annex.Branch.change f $ \_old -> buildLog (S.singleton ent)
|