AssociatedFile newtype

To prevent any further mistakes like 301aff34c4

This commit was sponsored by Francois Marier on Patreon.
This commit is contained in:
Joey Hess 2017-03-10 13:12:24 -04:00
parent 2cd7496210
commit c8e1e3dada
No known key found for this signature in database
GPG key ID: C910D9222512E3C7
43 changed files with 179 additions and 138 deletions

View file

@ -503,9 +503,10 @@ checkChangeContent change@(Change { changeInfo = i }) =
Just k -> whenM (scanComplete <$> getDaemonStatus) $ do
present <- liftAnnex $ inAnnex k
void $ if present
then queueTransfers "new file created" Next k (Just f) Upload
else queueTransfers "new or renamed file wanted" Next k (Just f) Download
handleDrops "file renamed" present k (Just f) []
then queueTransfers "new file created" Next k af Upload
else queueTransfers "new or renamed file wanted" Next k af Download
handleDrops "file renamed" present k af []
where
f = changeFile change
af = AssociatedFile (Just f)
checkChangeContent _ = noop

View file

@ -190,7 +190,7 @@ runActivity' urlrenderer (ScheduledSelfFsck _ d) = do
void $ repairWhenNecessary urlrenderer u Nothing fsckresults
mapM_ reget =<< liftAnnex (dirKeys gitAnnexBadDir)
where
reget k = queueTransfers "fsck found bad file; redownloading" Next k Nothing Download
reget k = queueTransfers "fsck found bad file; redownloading" Next k (AssociatedFile Nothing) Download
runActivity' urlrenderer (ScheduledRemoteFsck u s d) = dispatch =<< liftAnnex (remoteFromUUID u)
where
dispatch Nothing = debug ["skipping remote fsck of uuid without a configured remote", fromUUID u, fromSchedule s]

View file

@ -190,8 +190,8 @@ dailyCheck urlrenderer = do
unused <- liftAnnex unusedKeys'
void $ liftAnnex $ setUnusedKeys unused
forM_ unused $ \k -> do
unlessM (queueTransfers "unused" Later k Nothing Upload) $
handleDrops "unused" True k Nothing []
unlessM (queueTransfers "unused" Later k (AssociatedFile Nothing) Upload) $
handleDrops "unused" True k (AssociatedFile Nothing) []
return True
where

View file

@ -154,8 +154,9 @@ expensiveScan urlrenderer rs = batch <~> do
enqueue f (r, t) =
queueTransferWhenSmall "expensive scan found missing object"
(Just f) t r
(AssociatedFile (Just f)) t r
findtransfers f unwanted key = do
let af = AssociatedFile (Just f)
{- The syncable remotes may have changed since this
- scan began. -}
syncrs <- syncDataRemotes <$> getDaemonStatus
@ -163,14 +164,14 @@ expensiveScan urlrenderer rs = batch <~> do
present <- liftAnnex $ inAnnex key
liftAnnex $ handleDropsFrom locs syncrs
"expensive scan found too many copies of object"
present key (Just f) [] callCommandAction
present key af [] callCommandAction
liftAnnex $ do
let slocs = S.fromList locs
let use a = return $ mapMaybe (a key slocs) syncrs
ts <- if present
then filterM (wantSend True (Just key) (Just f) . Remote.uuid . fst)
then filterM (wantSend True (Just key) af . Remote.uuid . fst)
=<< use (genTransfer Upload False)
else ifM (wantGet True (Just key) (Just f))
else ifM (wantGet True (Just key) af)
( use (genTransfer Download True) , return [] )
let unwanted' = S.difference unwanted slocs
return (unwanted', ts)