summaryrefslogtreecommitdiff
path: root/Command/Unused.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-07-25 19:51:08 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-07-25 19:51:08 -0400
commit37cd95924708fc8a1b2003eae107904d0064212d (patch)
tree3edd9449ac89f99fe8c0664d40638bf2596d15d8 /Command/Unused.hs
parent62a2644d670e61ac8f6d6d24c49c640d00ba097d (diff)
unused: No longer shows as unused tmp files that are actively being transferred.
Diffstat (limited to 'Command/Unused.hs')
-rw-r--r--Command/Unused.hs16
1 files changed, 11 insertions, 5 deletions
diff --git a/Command/Unused.hs b/Command/Unused.hs
index fd6cf6575..0a060aae6 100644
--- a/Command/Unused.hs
+++ b/Command/Unused.hs
@@ -23,6 +23,7 @@ import Logs.Unused
import Annex.Content
import Utility.FileMode
import Logs.Location
+import Logs.Transfer
import qualified Annex
import qualified Git
import qualified Git.Command
@@ -61,8 +62,8 @@ start = do
checkUnused :: CommandPerform
checkUnused = chain 0
[ check "" unusedMsg $ findunused =<< Annex.getState Annex.fast
- , check "bad" staleBadMsg $ staleKeysPrune gitAnnexBadDir
- , check "tmp" staleTmpMsg $ staleKeysPrune gitAnnexTmpDir
+ , check "bad" staleBadMsg $ staleKeysPrune gitAnnexBadDir False
+ , check "tmp" staleTmpMsg $ staleKeysPrune gitAnnexTmpDir True
]
where
findunused True = do
@@ -289,8 +290,8 @@ withKeysReferencedInGitRef a ref = do
-
- Also, stale keys that can be proven to have no value are deleted.
-}
-staleKeysPrune :: (Git.Repo -> FilePath) -> Annex [Key]
-staleKeysPrune dirspec = do
+staleKeysPrune :: (Git.Repo -> FilePath) -> Bool -> Annex [Key]
+staleKeysPrune dirspec nottransferred = do
contents <- staleKeys dirspec
dups <- filterM inAnnex contents
@@ -299,7 +300,12 @@ staleKeysPrune dirspec = do
dir <- fromRepo dirspec
liftIO $ forM_ dups $ \t -> removeFile $ dir </> keyFile t
- return stale
+ if nottransferred
+ then do
+ inprogress <- S.fromList . map (transferKey . fst)
+ <$> getTransfers
+ return $ filter (`S.notMember` inprogress) stale
+ else return stale
staleKeys :: (Git.Repo -> FilePath) -> Annex [Key]
staleKeys dirspec = do