prettify
This commit is contained in:
parent
5df18b311a
commit
83bbb3bc93
1 changed files with 28 additions and 28 deletions
|
@ -54,14 +54,11 @@ start = do
|
||||||
next action
|
next action
|
||||||
|
|
||||||
checkUnused :: CommandPerform
|
checkUnused :: CommandPerform
|
||||||
checkUnused = do
|
checkUnused = chain 0
|
||||||
unused <- findunused =<< Annex.getState Annex.fast
|
[ check "" unusedMsg $ findunused =<< Annex.getState Annex.fast
|
||||||
stalebad <- staleKeysPrune gitAnnexBadDir
|
, check "bad" staleBadMsg $ staleKeysPrune gitAnnexBadDir
|
||||||
staletmp <- staleKeysPrune gitAnnexTmpDir
|
, check "tmp" staleTmpMsg $ staleKeysPrune gitAnnexTmpDir
|
||||||
_ <- list "" unusedMsg unused 0 >>=
|
]
|
||||||
list "bad" staleBadMsg stalebad >>=
|
|
||||||
list "tmp" staleTmpMsg staletmp
|
|
||||||
next $ return True
|
|
||||||
where
|
where
|
||||||
findunused True = do
|
findunused True = do
|
||||||
showNote "fast mode enabled; only finding stale files"
|
showNote "fast mode enabled; only finding stale files"
|
||||||
|
@ -69,25 +66,32 @@ checkUnused = do
|
||||||
findunused False = do
|
findunused False = do
|
||||||
showAction "checking for unused data"
|
showAction "checking for unused data"
|
||||||
excludeReferenced =<< getKeysPresent
|
excludeReferenced =<< getKeysPresent
|
||||||
list file msg l c = do
|
chain _ [] = next $ return True
|
||||||
|
chain v (a:as) = do
|
||||||
|
v' <- a v
|
||||||
|
chain v' as
|
||||||
|
|
||||||
|
checkRemoteUnused :: String -> CommandPerform
|
||||||
|
checkRemoteUnused name = go =<< fromJust <$> Remote.byName (Just name)
|
||||||
|
where
|
||||||
|
go r = do
|
||||||
|
showAction "checking for unused data"
|
||||||
|
_ <- check "" (remoteUnusedMsg r) (remoteunused r) 0
|
||||||
|
next $ return True
|
||||||
|
remoteunused r =
|
||||||
|
excludeReferenced =<< loggedKeysFor (Remote.uuid r)
|
||||||
|
|
||||||
|
check :: FilePath -> ([(Int, Key)] -> String) -> Annex [Key] -> Int -> Annex Int
|
||||||
|
check file msg a c = do
|
||||||
|
l <- a
|
||||||
let unusedlist = number c l
|
let unusedlist = number c l
|
||||||
unless (null l) $ showLongNote $ msg unusedlist
|
unless (null l) $ showLongNote $ msg unusedlist
|
||||||
writeUnusedFile file unusedlist
|
writeUnusedFile file unusedlist
|
||||||
return $ c + length l
|
return $ c + length l
|
||||||
|
|
||||||
checkRemoteUnused :: String -> CommandPerform
|
number :: Int -> [a] -> [(Int, a)]
|
||||||
checkRemoteUnused name = do
|
number _ [] = []
|
||||||
checkRemoteUnused' =<< fromJust <$> Remote.byName (Just name)
|
number n (x:xs) = (n+1, x) : number (n+1) xs
|
||||||
next $ return True
|
|
||||||
|
|
||||||
checkRemoteUnused' :: Remote -> Annex ()
|
|
||||||
checkRemoteUnused' r = do
|
|
||||||
showAction "checking for unused data"
|
|
||||||
remotehas <- loggedKeysFor (Remote.uuid r)
|
|
||||||
remoteunused <- excludeReferenced remotehas
|
|
||||||
let list = number 0 remoteunused
|
|
||||||
writeUnusedFile "" list
|
|
||||||
unless (null remoteunused) $ showLongNote $ remoteUnusedMsg r list
|
|
||||||
|
|
||||||
writeUnusedFile :: FilePath -> [(Int, Key)] -> Annex ()
|
writeUnusedFile :: FilePath -> [(Int, Key)] -> Annex ()
|
||||||
writeUnusedFile prefix l = do
|
writeUnusedFile prefix l = do
|
||||||
|
@ -101,10 +105,6 @@ table l = " NUMBER KEY" : map cols l
|
||||||
cols (n,k) = " " ++ pad 6 (show n) ++ " " ++ show k
|
cols (n,k) = " " ++ pad 6 (show n) ++ " " ++ show k
|
||||||
pad n s = s ++ replicate (n - length s) ' '
|
pad n s = s ++ replicate (n - length s) ' '
|
||||||
|
|
||||||
number :: Int -> [a] -> [(Int, a)]
|
|
||||||
number _ [] = []
|
|
||||||
number n (x:xs) = (n+1, x) : number (n+1) xs
|
|
||||||
|
|
||||||
staleTmpMsg :: [(Int, Key)] -> String
|
staleTmpMsg :: [(Int, Key)] -> String
|
||||||
staleTmpMsg t = unlines $
|
staleTmpMsg t = unlines $
|
||||||
["Some partially transferred data exists in temporary files:"]
|
["Some partially transferred data exists in temporary files:"]
|
||||||
|
|
Loading…
Add table
Reference in a new issue