don't rely on hasKeyCheap in the transfer scan

The problem with using it here is that, if a removable drive is scanned
and gets disconnected during the scan, testing for all the files will
indicate it doesn't have them, and the scan is logged as completed
successfully, without necessary transfers being queued.
This commit is contained in:
Joey Hess 2012-08-23 15:48:31 -04:00
parent 6420fa6c08
commit 37b960d3b0

View file

@ -39,8 +39,6 @@ transferScannerThread st dstatus scanremotes transferqueue = do
void $ alertWhile dstatus (scanAlert r) $ void $ alertWhile dstatus (scanAlert r) $
expensiveScan st dstatus transferqueue r expensiveScan st dstatus transferqueue r
liftIO $ debug thisThread ["finished scan of", show r] liftIO $ debug thisThread ["finished scan of", show r]
runThreadState st $ inRepo $
transferScanned $ Remote.uuid r
else failedTransferScan st dstatus transferqueue r else failedTransferScan st dstatus transferqueue r
{- This is a cheap scan for failed transfers involving a remote. -} {- This is a cheap scan for failed transfers involving a remote. -}
@ -66,6 +64,8 @@ expensiveScan st dstatus transferqueue r = do
g <- runThreadState st $ fromRepo id g <- runThreadState st $ fromRepo id
files <- LsFiles.inRepo [] g files <- LsFiles.inRepo [] g
go files go files
runThreadState st $ inRepo $
transferScanned $ Remote.uuid r
return True return True
where where
go [] = noop go [] = noop
@ -90,12 +90,6 @@ expensiveScan st dstatus transferqueue r = do
u = Remote.uuid r u = Remote.uuid r
enqueue f t = queueTransferWhenSmall transferqueue dstatus (Just f) t r enqueue f t = queueTransferWhenSmall transferqueue dstatus (Just f) t r
{- Look directly in remote for the key when it's cheap; remotehas key = elem
- otherwise rely on the location log. -}
remotehas key
| Remote.hasKeyCheap r = (==)
<$> pure (Right True)
<*> Remote.hasKey r key
| otherwise = elem
<$> pure u <$> pure u
<*> loggedLocations key <*> loggedLocations key