From c6100aa5ccdcae5b5805b17b7ae5eb16b616ac8d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 25 Jul 2013 19:51:08 -0400 Subject: [PATCH] unused: No longer shows as unused tmp files that are actively being transferred. --- Command/Unused.hs | 16 +++++++++++----- debian/changelog | 2 ++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Command/Unused.hs b/Command/Unused.hs index fd6cf65751..0a060aae61 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 diff --git a/debian/changelog b/debian/changelog index 7ea3eb4132..0c42b91757 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,6 +13,8 @@ git-annex (4.20130724) UNRELEASED; urgency=low core.fsyncobjectfiles, to help prevent data loss when the drive is yanked. * Always build with -threaded, to avoid a deadlock when communicating with gpg. + * unused: No longer shows as unused tmp files that are actively being + transferred. -- Joey Hess Tue, 23 Jul 2013 12:39:48 -0400