summaryrefslogtreecommitdiff
path: root/Annex/Drop.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-01-21 16:08:19 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-01-21 16:08:59 -0400
commitd5f7fb27aad3e2e9c4bebb9ccd5577af8deb25c7 (patch)
tree838837e3112942fcf0f82cfc7f68e62a6f4e7a6e /Annex/Drop.hs
parent9a8709f064c7608859b3155a752093b29cd8ab98 (diff)
reorganize numcopies code (no behavior changes)
Move stuff into Logs.NumCopies. Add a NumCopies newtype. Better names for various serialization classes that are specific to one thing or another.
Diffstat (limited to 'Annex/Drop.hs')
-rw-r--r--Annex/Drop.hs10
1 files changed, 6 insertions, 4 deletions
diff --git a/Annex/Drop.hs b/Annex/Drop.hs
index e307852f2..afd6303b0 100644
--- a/Annex/Drop.hs
+++ b/Annex/Drop.hs
@@ -9,6 +9,7 @@ module Annex.Drop where
import Common.Annex
import Logs.Trust
+import Logs.NumCopies
import Types.Remote (uuid)
import qualified Remote
import qualified Command.Drop
@@ -59,8 +60,9 @@ handleDropsFrom locs rs reason fromhere key (Just afile) knownpresentremote runn
where
getcopies fs = do
(untrusted, have) <- trustPartition UnTrusted locs
- numcopies <- maximum <$> mapM (getNumCopies <=< numCopies) fs
- return (length have, numcopies, S.fromList untrusted)
+ numcopies <- maximum
+ <$> mapM (getNumCopies <=< getFileNumCopies) fs
+ return (NumCopies (length have), numcopies, S.fromList untrusted)
{- Check that we have enough copies still to drop the content.
- When the remote being dropped from is untrusted, it was not
@@ -72,7 +74,7 @@ handleDropsFrom locs rs reason fromhere key (Just afile) knownpresentremote runn
| otherwise = have > numcopies
decrcopies (have, numcopies, untrusted) Nothing =
- (have - 1, numcopies, untrusted)
+ (NumCopies (fromNumCopies have - 1), numcopies, untrusted)
decrcopies v@(_have, _numcopies, untrusted) (Just u)
| S.member u untrusted = v
| otherwise = decrcopies v Nothing
@@ -92,7 +94,7 @@ handleDropsFrom locs rs reason fromhere key (Just afile) knownpresentremote runn
[ "dropped"
, afile
, "(from " ++ maybe "here" show u ++ ")"
- , "(copies now " ++ show (have - 1) ++ ")"
+ , "(copies now " ++ show (fromNumCopies have - 1) ++ ")"
, ": " ++ reason
]
return $ decrcopies n u