final readonly values moves to AnnexRead

At this point I've checked all AnnexState values and these were all that
remained that could move.

Pity that Annex.repo can't move, but it gets modified sometimes..

A couple of AnnexState values are set by options and could be AnnexRead,
but happen to use Annex when being set.

Sponsored-by: Max Thoursie on Patreon
This commit is contained in:
Joey Hess 2022-06-28 16:02:01 -04:00
parent 6984bcdba9
commit 8040ecf9b8
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 12 additions and 11 deletions

View file

@ -126,6 +126,8 @@ data AnnexRead = AnnexRead
, forcenumcopies :: Maybe NumCopies
, forcemincopies :: Maybe MinCopies
, forcebackend :: Maybe String
, useragent :: Maybe String
, desktopnotify :: DesktopNotify
}
newAnnexRead :: GitConfig -> IO AnnexRead
@ -152,6 +154,8 @@ newAnnexRead c = do
, forcebackend = Nothing
, forcenumcopies = Nothing
, forcemincopies = Nothing
, useragent = Nothing
, desktopnotify = mempty
}
-- Values that can change while running an Annex action.
@ -190,14 +194,12 @@ data AnnexState = AnnexState
, fields :: M.Map String String
, cleanupactions :: M.Map CleanupAction (Annex ())
, sentinalstatus :: Maybe SentinalStatus
, useragent :: Maybe String
, errcounter :: Integer
, skippedfiles :: Bool
, adjustedbranchrefreshcounter :: Integer
, unusedkeys :: Maybe (S.Set Key)
, tempurls :: M.Map Key URLString
, existinghooks :: M.Map Git.Hook.Hook Bool
, desktopnotify :: DesktopNotify
, workers :: Maybe (TMVar (WorkerPool (AnnexState, AnnexRead)))
, cachedcurrentbranch :: (Maybe (Maybe Git.Branch, Maybe Adjustment))
, cachedgitenv :: Maybe (AltIndexFile, FilePath, [(String, String)])
@ -245,14 +247,12 @@ newAnnexState c r = do
, fields = M.empty
, cleanupactions = M.empty
, sentinalstatus = Nothing
, useragent = Nothing
, errcounter = 0
, skippedfiles = False
, adjustedbranchrefreshcounter = 0
, unusedkeys = Nothing
, tempurls = M.empty
, existinghooks = M.empty
, desktopnotify = mempty
, workers = Nothing
, cachedcurrentbranch = Nothing
, cachedgitenv = Nothing

View file

@ -48,7 +48,7 @@ defaultUserAgent :: U.UserAgent
defaultUserAgent = "git-annex/" ++ BuildInfo.packageversion
getUserAgent :: Annex U.UserAgent
getUserAgent = Annex.getState $
getUserAgent = Annex.getRead $
fromMaybe defaultUserAgent . Annex.useragent
getUrlOptions :: Annex U.UrlOptions

View file

@ -78,7 +78,7 @@ gitAnnexGlobalOptions = commonGlobalOptions ++
<> help "override git configuration setting"
<> hidden
)
, globalOption (setAnnexState . setuseragent) $ strOption
, globalOption setuseragent $ strOption
( long "user-agent" <> metavar paramName
<> help "override default User-Agent"
<> hidden
@ -88,12 +88,12 @@ gitAnnexGlobalOptions = commonGlobalOptions ++
<> help "deprecated, does not trust Amazon Glacier inventory"
<> hidden
)
, globalFlag (setAnnexState $ setdesktopnotify mkNotifyFinish)
, globalFlag (setdesktopnotify mkNotifyFinish)
( long "notify-finish"
<> help "show desktop notification after transfer finishes"
<> hidden
)
, globalFlag (setAnnexState $ setdesktopnotify mkNotifyStart)
, globalFlag (setdesktopnotify mkNotifyStart)
( long "notify-start"
<> help "show desktop notification after transfer starts"
<> hidden
@ -102,9 +102,9 @@ gitAnnexGlobalOptions = commonGlobalOptions ++
where
setnumcopies n = setAnnexRead $ \rd -> rd { Annex.forcenumcopies = Just $ configuredNumCopies n }
setmincopies n = setAnnexRead $ \rd -> rd { Annex.forcemincopies = Just $ configuredMinCopies n }
setuseragent v = Annex.changeState $ \s -> s { Annex.useragent = Just v }
setuseragent v = setAnnexRead $ \rd -> rd { Annex.useragent = Just v }
setdesktopnotify v = setAnnexRead $ \rd -> rd { Annex.desktopnotify = Annex.desktopnotify rd <> v }
setgitconfig v = Annex.addGitConfigOverride v
setdesktopnotify v = Annex.changeState $ \s -> s { Annex.desktopnotify = Annex.desktopnotify s <> v }
{- Parser that accepts all non-option params. -}
cmdParams :: CmdParamsDesc -> Parser CmdParams

View file

@ -4,4 +4,5 @@ anything that never needs to be modified while git-annex is running can be
moved to AnnexRead for a performance win and also to make clean how it's
used. --[[Joey]]
Many things have been moved, but there are certainly others that can be.
> [[done]]; all AnnexState fields have been checked and all that can be
> made readonly are. --[[Joey]]