display new empty repos in maxsize table

A new repo that has no location log info yet, but has an entry in
uuid.log has 0 size, so make RepoSize aware of that.

Note that a new repo that does not yet appear in uuid.log will still not
be displayed.

When a remote is added but not synced with yet, it has no uuid.log
entry. If git-annex maxsize is used to configure that remote, it needs
to appear in the maxsize table, and the change to Command.MaxSize takes
care of that.
This commit is contained in:
Joey Hess 2024-08-22 07:03:22 -04:00
parent a643699b7b
commit 3fe67744b1
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 23 additions and 23 deletions

View file

@ -76,9 +76,16 @@ sizeOverview o = do
descmap <- Remote.uuidDescriptions
deadset <- S.fromList <$> trustGet DeadTrusted
maxsizes <- getMaxSizes
reposizes <- flip M.withoutKeys deadset <$> getRepoSizes True
reposizes <- getRepoSizes True
-- Add repos too new and empty to have a reposize,
-- whose maxsize has been set.
let reposizes' = foldl'
(\m u -> M.insertWith (flip const) u (RepoSize 0) m)
reposizes
(M.keys maxsizes)
let reposizes'' = flip M.withoutKeys deadset reposizes'
let l = reverse $ sortOn snd $ M.toList $
M.mapWithKey (gather maxsizes) reposizes
M.mapWithKey (gather maxsizes) reposizes''
v <- Remote.prettyPrintUUIDsWith' False (Just "size")
"repositories" descmap showsizes l
showRaw $ encodeBS $ tablerow (zip widths headers)
@ -89,11 +96,10 @@ sizeOverview o = do
sizefield = "size" :: T.Text
maxsizefield = "maxsize" :: T.Text
gather maxsizes u (RepoSize currsize) = Just $
M.fromList
[ (sizefield, Just currsize)
, (maxsizefield, fromMaxSize <$> M.lookup u maxsizes)
]
gather maxsizes u (RepoSize currsize) = Just $ M.fromList
[ (sizefield, Just currsize)
, (maxsizefield, fromMaxSize <$> M.lookup u maxsizes)
]
(widths, headers) = unzip
[ (7, "size")