summaryrefslogtreecommitdiff
path: root/Assistant
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-10-18 16:05:43 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-10-18 16:05:43 -0400
commita32043b86f1ad52ce33ffba92e6d3a57cff81bfb (patch)
tree982d3e55ce7bf15c106e748c1765b2f4bd41c3ba /Assistant
parentd956edbea525138445d4f2d928041e813896d9cd (diff)
check and drop after uploads
Diffstat (limited to 'Assistant')
-rw-r--r--Assistant/Drop.hs17
-rw-r--r--Assistant/Threads/TransferScanner.hs2
-rw-r--r--Assistant/Threads/TransferWatcher.hs13
3 files changed, 18 insertions, 14 deletions
diff --git a/Assistant/Drop.hs b/Assistant/Drop.hs
index dea5934ee..cf20ef5b1 100644
--- a/Assistant/Drop.hs
+++ b/Assistant/Drop.hs
@@ -18,19 +18,18 @@ import Command
import Annex.Wanted
import Config
-{- Drop from syncable remotes when allowed by the preferred content and
+{- Drop from local and/or remote when allowed by the preferred content and
- numcopies settings. -}
-handleRemoteDrops :: DaemonStatusHandle -> Key -> AssociatedFile -> Annex ()
-handleRemoteDrops dstatus key (Just f) = do
+handleDrops :: DaemonStatusHandle -> Bool -> Key -> AssociatedFile -> Annex ()
+handleDrops _ _ _ Nothing = noop
+handleDrops dstatus fromhere key f = do
syncrs <- liftIO $ syncRemotes <$> getDaemonStatus dstatus
locs <- loggedLocations key
- handleDrops locs syncrs False f key
-handleRemoteDrops _ _ _ = noop
+ handleDrops' locs syncrs fromhere key f
-{- Drop from local and/or remote when allowed by the preferred content and
- - numcopies settings. -}
-handleDrops :: [UUID] -> [Remote] -> Bool -> FilePath -> Key -> Annex ()
-handleDrops locs rs fromhere f key
+handleDrops' :: [UUID] -> [Remote] -> Bool -> Key -> AssociatedFile -> Annex ()
+handleDrops' _ _ _ _ Nothing = noop
+handleDrops' locs rs fromhere key (Just f)
| fromhere = do
n <- getcopies
if checkcopies n
diff --git a/Assistant/Threads/TransferScanner.hs b/Assistant/Threads/TransferScanner.hs
index 4cd6915f5..631c36b02 100644
--- a/Assistant/Threads/TransferScanner.hs
+++ b/Assistant/Threads/TransferScanner.hs
@@ -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 key (Just f)
let slocs = S.fromList locs
let use a = return $ catMaybes $ map (a key slocs) syncrs
diff --git a/Assistant/Threads/TransferWatcher.hs b/Assistant/Threads/TransferWatcher.hs
index 19009756b..e82e4fb08 100644
--- a/Assistant/Threads/TransferWatcher.hs
+++ b/Assistant/Threads/TransferWatcher.hs
@@ -108,16 +108,21 @@ onDel st dstatus transferqueue file _ = case parseTransferFile file of
{- 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. -}
+ - Downloading a file may have caused a remote to not want it;
+ - 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 st dstatus transferqueue t (Just info)
| transferDirection t == Download = runThreadState st $
whenM (inAnnex $ transferKey t) $ do
- handleRemoteDrops dstatus
+ handleDrops dstatus False
(transferKey t) (associatedFile info)
queueTransfersMatching (/= transferUUID t)
Later transferqueue dstatus
(transferKey t) (associatedFile info) Upload
- | otherwise = noop
+ | otherwise = runThreadState st $
+ handleDrops dstatus True (transferKey t) (associatedFile info)
finishedTransfer _ _ _ _ _ = noop