check and drop after uploads

This commit is contained in:
Joey Hess 2012-10-18 16:05:43 -04:00
parent 0c6a1ec87d
commit 9c89924c05
4 changed files with 21 additions and 17 deletions

View file

@ -18,19 +18,18 @@ import Command
import Annex.Wanted import Annex.Wanted
import Config import Config
{- Drop from syncable remotes when allowed by the preferred content and
- numcopies settings. -}
handleRemoteDrops :: DaemonStatusHandle -> Key -> AssociatedFile -> Annex ()
handleRemoteDrops dstatus key (Just f) = do
syncrs <- liftIO $ syncRemotes <$> getDaemonStatus dstatus
locs <- loggedLocations key
handleDrops locs syncrs False f key
handleRemoteDrops _ _ _ = noop
{- Drop from local and/or remote when allowed by the preferred content and {- Drop from local and/or remote when allowed by the preferred content and
- numcopies settings. -} - numcopies settings. -}
handleDrops :: [UUID] -> [Remote] -> Bool -> FilePath -> Key -> Annex () handleDrops :: DaemonStatusHandle -> Bool -> Key -> AssociatedFile -> Annex ()
handleDrops locs rs fromhere f key handleDrops _ _ _ Nothing = noop
handleDrops dstatus fromhere key f = do
syncrs <- liftIO $ syncRemotes <$> getDaemonStatus dstatus
locs <- loggedLocations key
handleDrops' locs syncrs fromhere key f
handleDrops' :: [UUID] -> [Remote] -> Bool -> Key -> AssociatedFile -> Annex ()
handleDrops' _ _ _ _ Nothing = noop
handleDrops' locs rs fromhere key (Just f)
| fromhere = do | fromhere = do
n <- getcopies n <- getcopies
if checkcopies n if checkcopies n

View file

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

View file

@ -108,16 +108,21 @@ onDel st dstatus transferqueue file _ = case parseTransferFile file of
{- Queue uploads of files we successfully downloaded, spreading them {- Queue uploads of files we successfully downloaded, spreading them
- out to other reachable remotes. - out to other reachable remotes.
- -
- Also, downloading a file may have caused a remote to not want it, - Downloading a file may have caused a remote to not want it;
- so drop it from the remote. -} - so drop it from the remote.
-
- Uploading a file may cause the local repo, or some other remote to not
- want it; handle that too.
-}
finishedTransfer :: ThreadState -> DaemonStatusHandle -> TransferQueue -> Transfer -> Maybe TransferInfo -> IO () finishedTransfer :: ThreadState -> DaemonStatusHandle -> TransferQueue -> Transfer -> Maybe TransferInfo -> IO ()
finishedTransfer st dstatus transferqueue t (Just info) finishedTransfer st dstatus transferqueue t (Just info)
| transferDirection t == Download = runThreadState st $ | transferDirection t == Download = runThreadState st $
whenM (inAnnex $ transferKey t) $ do whenM (inAnnex $ transferKey t) $ do
handleRemoteDrops dstatus handleDrops dstatus False
(transferKey t) (associatedFile info) (transferKey t) (associatedFile info)
queueTransfersMatching (/= transferUUID t) queueTransfersMatching (/= transferUUID t)
Later transferqueue dstatus Later transferqueue dstatus
(transferKey t) (associatedFile info) Upload (transferKey t) (associatedFile info) Upload
| otherwise = noop | otherwise = runThreadState st $
handleDrops dstatus True (transferKey t) (associatedFile info)
finishedTransfer _ _ _ _ _ = noop finishedTransfer _ _ _ _ _ = noop

View file

@ -35,7 +35,7 @@ the same content, this gets tricky. Let's assume there are not.)
again, and should cause it to be transferred in that case, which doesn't again, and should cause it to be transferred in that case, which doesn't
happen either..) happen either..)
3. we get a file (`in`, `copies`) **done** 3. we get a file (`in`, `copies`) **done**
4. we sent a file to a remote (`in`, `copies`) 4. we sent a file (`in`, `copies`) **done**
5. some other repository drops the file (`in`, `copies` .. However, it's 5. some other repository drops the file (`in`, `copies` .. However, it's
unlikely that an expression would prefer content when *more* copies unlikely that an expression would prefer content when *more* copies
exisited, and want to drop it when less do. That's nearly a pathological exisited, and want to drop it when less do. That's nearly a pathological