aboutsummaryrefslogtreecommitdiff
path: root/Annex/Drop.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-03-10 13:12:24 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-03-10 13:35:31 -0400
commit8cb9381befed4174624edfc80e09185c9340b4f6 (patch)
treee5d2041ff38502b1f8a5ef9caa6515cccfcea555 /Annex/Drop.hs
parente230fd58b5f5d5d16f87e1bd5c0f2e553f2ae5a2 (diff)
AssociatedFile newtype
To prevent any further mistakes like 1a497cefb47557f0b4788c606f9071be422b2511 This commit was sponsored by Francois Marier on Patreon.
Diffstat (limited to 'Annex/Drop.hs')
-rw-r--r--Annex/Drop.hs12
1 files changed, 7 insertions, 5 deletions
diff --git a/Annex/Drop.hs b/Annex/Drop.hs
index cd0168a9f..1723bce0d 100644
--- a/Annex/Drop.hs
+++ b/Annex/Drop.hs
@@ -55,8 +55,8 @@ handleDropsFrom locs rs reason fromhere key afile preverified runner = do
map (`fromTopFilePath` g) <$> Database.Keys.getAssociatedFiles key
)
let fs = case afile of
- Just f -> nub (f : l)
- Nothing -> l
+ AssociatedFile (Just f) -> nub (f : l)
+ AssociatedFile Nothing -> l
n <- getcopies fs
void $ if fromhere && checkcopies n Nothing
then go fs rs n >>= dropl fs
@@ -93,9 +93,9 @@ handleDropsFrom locs rs reason fromhere key afile preverified runner = do
checkdrop fs n u a
| null fs = check $ -- no associated files; unused content
- wantDrop True u (Just key) Nothing
+ wantDrop True u (Just key) (AssociatedFile Nothing)
| otherwise = check $
- allM (wantDrop True u (Just key) . Just) fs
+ allM (wantDrop True u (Just key) . AssociatedFile . Just) fs
where
check c = ifM c
( dodrop n u a
@@ -107,7 +107,9 @@ handleDropsFrom locs rs reason fromhere key afile preverified runner = do
( do
liftIO $ debugM "drop" $ unwords
[ "dropped"
- , fromMaybe (key2file key) afile
+ , case afile of
+ AssociatedFile Nothing -> key2file key
+ AssociatedFile (Just af) -> af
, "(from " ++ maybe "here" show u ++ ")"
, "(copies now " ++ show (fromNumCopies have - 1) ++ ")"
, ": " ++ reason