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
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
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
|
|
|
|
|
2014-01-21 20:08:19 +00:00
|
|
|
readLog :: (Ord v, SingleValueSerializable v) => FilePath -> Annex (Log v)
|
2014-01-20 20:47:56 +00:00
|
|
|
readLog = parseLog <$$> Annex.Branch.get
|
|
|
|
|
2014-01-21 20:08:19 +00:00
|
|
|
getLog :: (Ord v, SingleValueSerializable v) => FilePath -> Annex (Maybe v)
|
2014-01-20 20:47:56 +00:00
|
|
|
getLog = newestValue <$$> readLog
|
|
|
|
|
2014-01-21 20:08:19 +00:00
|
|
|
setLog :: (SingleValueSerializable v) => FilePath -> 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
|
2014-01-20 20:47:56 +00:00
|
|
|
Annex.Branch.change f $ \_old -> showLog (S.singleton ent)
|