2014-01-20 20:47:56 +00:00
|
|
|
{- git-annex numcopies log
|
|
|
|
-
|
|
|
|
- Copyright 2014 Joey Hess <joey@kitenet.net>
|
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
|
|
|
|
2014-01-21 20:08:19 +00:00
|
|
|
module Logs.NumCopies (
|
|
|
|
setGlobalNumCopies,
|
|
|
|
getGlobalNumCopies,
|
|
|
|
globalNumCopiesLoad,
|
|
|
|
) where
|
2014-01-20 20:47:56 +00:00
|
|
|
|
|
|
|
import Common.Annex
|
|
|
|
import qualified Annex
|
2014-01-21 20:08:19 +00:00
|
|
|
import Types.NumCopies
|
2014-01-20 20:47:56 +00:00
|
|
|
import Logs
|
|
|
|
import Logs.SingleValue
|
|
|
|
|
2014-01-21 20:08:19 +00:00
|
|
|
instance SingleValueSerializable NumCopies where
|
|
|
|
serialize (NumCopies n) = show n
|
|
|
|
deserialize = NumCopies <$$> readish
|
2014-01-20 20:47:56 +00:00
|
|
|
|
2014-01-21 20:08:19 +00:00
|
|
|
setGlobalNumCopies :: NumCopies -> Annex ()
|
2014-01-20 20:47:56 +00:00
|
|
|
setGlobalNumCopies = setLog numcopiesLog
|
|
|
|
|
2014-01-21 21:08:49 +00:00
|
|
|
{- Value configured in the numcopies log. Cached for speed. -}
|
2014-01-21 20:08:19 +00:00
|
|
|
getGlobalNumCopies :: Annex (Maybe NumCopies)
|
|
|
|
getGlobalNumCopies = maybe globalNumCopiesLoad (return . Just)
|
2014-01-20 20:47:56 +00:00
|
|
|
=<< Annex.getState Annex.globalnumcopies
|
|
|
|
|
2014-01-21 20:08:19 +00:00
|
|
|
globalNumCopiesLoad :: Annex (Maybe NumCopies)
|
|
|
|
globalNumCopiesLoad = do
|
2014-01-20 20:47:56 +00:00
|
|
|
v <- getLog numcopiesLog
|
|
|
|
Annex.changeState $ \s -> s { Annex.globalnumcopies = v }
|
|
|
|
return v
|