check and drop unwanted content from remotes after receiving a transfer

This commit is contained in:
Joey Hess 2012-10-18 15:37:57 -04:00
parent dea125e1b7
commit ee9e0702a2
4 changed files with 33 additions and 28 deletions

View file

@ -125,7 +125,7 @@ expensiveScan st dstatus transferqueue rs = unless onlyweb $ do
syncrs <- liftIO $ syncRemotes <$> getDaemonStatus dstatus
present <- inAnnex key
handleDrops' locs syncrs present f key
handleDrops locs syncrs present f key
let slocs = S.fromList locs
let use a = return $ catMaybes $ map (a key slocs) syncrs

View file

@ -11,6 +11,7 @@ import Assistant.Common
import Assistant.ThreadedMonad
import Assistant.DaemonStatus
import Assistant.TransferQueue
import Assistant.Drop
import Annex.Content
import Logs.Transfer
import Utility.DirWatcher
@ -102,16 +103,21 @@ onDel st dstatus transferqueue file _ = case parseTransferFile file of
, show t
]
minfo <- removeTransfer dstatus t
finishedTransfer st dstatus transferqueue t minfo
{- Queue uploads of files we successfully downloaded,
- spreading them out to other reachable remotes. -}
case (minfo, transferDirection t) of
(Just info, Download) -> runThreadState st $
whenM (inAnnex $ transferKey t) $
queueTransfersMatching
(/= transferUUID t)
Later transferqueue dstatus
(transferKey t)
(associatedFile info)
Upload
_ -> noop
{- Queue uploads of files we successfully downloaded, spreading them
- out to other reachable remotes.
-
- Also, downloading a file may have caused a remote to not want it,
- so drop it from the remote. -}
finishedTransfer :: ThreadState -> DaemonStatusHandle -> TransferQueue -> Transfer -> Maybe TransferInfo -> IO ()
finishedTransfer st dstatus transferqueue t (Just info)
| transferDirection t == Download = runThreadState st $
whenM (inAnnex $ transferKey t) $ do
handleRemoteDrops dstatus
(transferKey t) (associatedFile info)
queueTransfersMatching (/= transferUUID t)
Later transferqueue dstatus
(transferKey t) (associatedFile info) Upload
| otherwise = noop
finishedTransfer _ _ _ _ _ = noop