c3d40b9ec3
Each command that first checks preferred content (and/or required content) and then does something that can change the sizes of repositories needs to call prepareLiveUpdate, and plumb it through the preferred content check and the location log update. So far, only Command.Drop is done. Many other commands that don't need to do this have been updated to keep working. There may be some calls to NoLiveUpdate in places where that should be done. All will need to be double checked. Not currently in a compilable state.
48 lines
1.3 KiB
Haskell
48 lines
1.3 KiB
Haskell
{- git-annex maxsize log
|
|
-
|
|
- Copyright 2024 Joey Hess <id@joeyh.name>
|
|
-
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
|
-}
|
|
|
|
module Logs.MaxSize (
|
|
MaxSize(..),
|
|
getMaxSizes,
|
|
recordMaxSize,
|
|
) where
|
|
|
|
import qualified Annex
|
|
import Annex.Common
|
|
import Logs
|
|
import Logs.UUIDBased
|
|
import Logs.MapLog
|
|
import qualified Annex.Branch
|
|
|
|
import qualified Data.Map as M
|
|
import Data.ByteString.Builder
|
|
import qualified Data.Attoparsec.ByteString as A
|
|
|
|
getMaxSizes :: Annex (M.Map UUID MaxSize)
|
|
getMaxSizes = maybe loadMaxSizes return =<< Annex.getState Annex.maxsizes
|
|
|
|
loadMaxSizes :: Annex (M.Map UUID MaxSize)
|
|
loadMaxSizes = do
|
|
maxsizes <- M.map value . fromMapLog . parseLogNew parseMaxSize
|
|
<$> Annex.Branch.get maxSizeLog
|
|
Annex.changeState $ \s -> s { Annex.maxsizes = Just maxsizes }
|
|
return maxsizes
|
|
|
|
recordMaxSize :: UUID -> MaxSize -> Annex ()
|
|
recordMaxSize uuid maxsize = do
|
|
c <- currentVectorClock
|
|
Annex.Branch.change (Annex.Branch.RegardingUUID [uuid]) maxSizeLog $
|
|
(buildLogNew buildMaxSize)
|
|
. changeLog c uuid maxsize
|
|
. parseLogNew parseMaxSize
|
|
|
|
buildMaxSize :: MaxSize -> Builder
|
|
buildMaxSize (MaxSize n) = byteString (encodeBS (show n))
|
|
|
|
parseMaxSize :: A.Parser MaxSize
|
|
parseMaxSize = maybe (fail "maxsize parse failed") (pure . MaxSize)
|
|
. readish . decodeBS =<< A.takeByteString
|