status: More accurate display of sizes of tmp and bad keys.
Can't trust the key size to be accurate for tmp and bad keys, so check actual file size. In the wild I saw the old code be wrong by a factor of about 100! If all tmp/bad keys are empty, they're not shown in status at all. Showing 0 bytes and suggesting to clean it up seemed weird..
This commit is contained in:
parent
83bbb3bc93
commit
89ee70c43a
2 changed files with 14 additions and 6 deletions
|
@ -211,12 +211,19 @@ showSizeKeys d = total ++ missingnote
|
|||
" keys of unknown size"
|
||||
|
||||
staleSize :: String -> (Git.Repo -> FilePath) -> Stat
|
||||
staleSize label dirspec = do
|
||||
keys <- lift (Command.Unused.staleKeys dirspec)
|
||||
if null keys
|
||||
then nostat
|
||||
else stat label $ json (++ aside "clean up with git-annex unused") $
|
||||
return $ showSizeKeys $ foldKeys keys
|
||||
staleSize label dirspec = go =<< lift (Command.Unused.staleKeys dirspec)
|
||||
where
|
||||
go [] = nostat
|
||||
go keys = onsize =<< sum <$> keysizes keys
|
||||
onsize 0 = nostat
|
||||
onsize size = stat label $
|
||||
json (++ aside "clean up with git-annex unused") $
|
||||
return $ roughSize storageUnits False size
|
||||
keysizes keys = map (fromIntegral . fileSize) <$> stats keys
|
||||
stats keys = do
|
||||
dir <- lift $ fromRepo dirspec
|
||||
liftIO $ forM keys $ \k ->
|
||||
getFileStatus (dir </> keyFile k)
|
||||
|
||||
aside :: String -> String
|
||||
aside s = " (" ++ s ++ ")"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue