try to drop unused object if it does not need to be transferred anywhere
This commit is contained in:
parent
3518c586cf
commit
964a181026
4 changed files with 22 additions and 13 deletions
|
@ -464,7 +464,7 @@ checkChangeContent change@(Change { changeInfo = i }) =
|
||||||
Nothing -> noop
|
Nothing -> noop
|
||||||
Just k -> whenM (scanComplete <$> getDaemonStatus) $ do
|
Just k -> whenM (scanComplete <$> getDaemonStatus) $ do
|
||||||
present <- liftAnnex $ inAnnex k
|
present <- liftAnnex $ inAnnex k
|
||||||
if present
|
void $ if present
|
||||||
then queueTransfers "new file created" Next k (Just f) Upload
|
then queueTransfers "new file created" Next k (Just f) Upload
|
||||||
else queueTransfers "new or renamed file wanted" Next k (Just f) Download
|
else queueTransfers "new or renamed file wanted" Next k (Just f) Download
|
||||||
handleDrops "file renamed" present k (Just f) Nothing
|
handleDrops "file renamed" present k (Just f) Nothing
|
||||||
|
|
|
@ -17,6 +17,7 @@ import Assistant.Common
|
||||||
import Assistant.DaemonStatus
|
import Assistant.DaemonStatus
|
||||||
import Assistant.Alert
|
import Assistant.Alert
|
||||||
import Assistant.Repair
|
import Assistant.Repair
|
||||||
|
import Assistant.Drop
|
||||||
import Assistant.Ssh
|
import Assistant.Ssh
|
||||||
import Assistant.TransferQueue
|
import Assistant.TransferQueue
|
||||||
import Assistant.Types.UrlRenderer
|
import Assistant.Types.UrlRenderer
|
||||||
|
@ -94,11 +95,11 @@ sanityCheckerHourlyThread = namedThread "SanityCheckerHourly" $ forever $ do
|
||||||
{- This thread wakes up daily to make sure the tree is in good shape. -}
|
{- This thread wakes up daily to make sure the tree is in good shape. -}
|
||||||
sanityCheckerDailyThread :: UrlRenderer -> NamedThread
|
sanityCheckerDailyThread :: UrlRenderer -> NamedThread
|
||||||
sanityCheckerDailyThread urlrenderer = namedThread "SanityCheckerDaily" $ forever $ do
|
sanityCheckerDailyThread urlrenderer = namedThread "SanityCheckerDaily" $ forever $ do
|
||||||
waitForNextCheck
|
|
||||||
|
|
||||||
debug ["starting sanity check"]
|
debug ["starting sanity check"]
|
||||||
void $ alertWhile sanityCheckAlert go
|
void $ alertWhile sanityCheckAlert go
|
||||||
debug ["sanity check complete"]
|
debug ["sanity check complete"]
|
||||||
|
waitForNextCheck
|
||||||
|
|
||||||
where
|
where
|
||||||
go = do
|
go = do
|
||||||
modifyDaemonStatus_ $ \s -> s { sanityCheckRunning = True }
|
modifyDaemonStatus_ $ \s -> s { sanityCheckRunning = True }
|
||||||
|
@ -172,11 +173,12 @@ dailyCheck urlrenderer = do
|
||||||
let (program', params') = batchmaker (program, [Param "unused"])
|
let (program', params') = batchmaker (program, [Param "unused"])
|
||||||
void $ liftIO $ boolSystem program' params'
|
void $ liftIO $ boolSystem program' params'
|
||||||
{- Invalidate unused keys cache, and queue transfers of all unused
|
{- Invalidate unused keys cache, and queue transfers of all unused
|
||||||
- keys. -}
|
- keys, or if no transfers are called for, drop them. -}
|
||||||
unused <- liftAnnex unusedKeys'
|
unused <- liftAnnex unusedKeys'
|
||||||
void $ liftAnnex $ setUnusedKeys unused
|
void $ liftAnnex $ setUnusedKeys unused
|
||||||
forM_ unused $ \k ->
|
forM_ unused $ \k -> do
|
||||||
queueTransfers "unused" Later k Nothing Upload
|
unlessM (queueTransfers "unused" Later k Nothing Upload) $
|
||||||
|
handleDrops "unused" True k Nothing Nothing
|
||||||
|
|
||||||
return True
|
return True
|
||||||
where
|
where
|
||||||
|
|
|
@ -51,14 +51,17 @@ stubInfo f r = stubTransferInfo
|
||||||
|
|
||||||
{- Adds transfers to queue for some of the known remotes.
|
{- Adds transfers to queue for some of the known remotes.
|
||||||
- Honors preferred content settings, only transferring wanted files. -}
|
- Honors preferred content settings, only transferring wanted files. -}
|
||||||
queueTransfers :: Reason -> Schedule -> Key -> AssociatedFile -> Direction -> Assistant ()
|
queueTransfers :: Reason -> Schedule -> Key -> AssociatedFile -> Direction -> Assistant Bool
|
||||||
queueTransfers = queueTransfersMatching (const True)
|
queueTransfers = queueTransfersMatching (const True)
|
||||||
|
|
||||||
{- Adds transfers to queue for some of the known remotes, that match a
|
{- Adds transfers to queue for some of the known remotes, that match a
|
||||||
- condition. Honors preferred content settings. -}
|
- condition. Honors preferred content settings. -}
|
||||||
queueTransfersMatching :: (UUID -> Bool) -> Reason -> Schedule -> Key -> AssociatedFile -> Direction -> Assistant ()
|
queueTransfersMatching :: (UUID -> Bool) -> Reason -> Schedule -> Key -> AssociatedFile -> Direction -> Assistant Bool
|
||||||
queueTransfersMatching matching reason schedule k f direction
|
queueTransfersMatching matching reason schedule k f direction
|
||||||
| direction == Download = whenM (liftAnnex $ wantGet True (Just k) f) go
|
| direction == Download = ifM (liftAnnex $ wantGet True (Just k) f)
|
||||||
|
( go
|
||||||
|
, return False
|
||||||
|
)
|
||||||
| otherwise = go
|
| otherwise = go
|
||||||
where
|
where
|
||||||
go = do
|
go = do
|
||||||
|
@ -67,9 +70,13 @@ queueTransfersMatching matching reason schedule k f direction
|
||||||
=<< syncDataRemotes <$> getDaemonStatus
|
=<< syncDataRemotes <$> getDaemonStatus
|
||||||
let matchingrs = filter (matching . Remote.uuid) rs
|
let matchingrs = filter (matching . Remote.uuid) rs
|
||||||
if null matchingrs
|
if null matchingrs
|
||||||
then defer
|
then do
|
||||||
else forM_ matchingrs $ \r ->
|
defer
|
||||||
enqueue reason schedule (gentransfer r) (stubInfo f r)
|
return False
|
||||||
|
else do
|
||||||
|
forM_ matchingrs $ \r ->
|
||||||
|
enqueue reason schedule (gentransfer r) (stubInfo f r)
|
||||||
|
return True
|
||||||
selectremotes rs
|
selectremotes rs
|
||||||
{- Queue downloads from all remotes that
|
{- Queue downloads from all remotes that
|
||||||
- have the key. The list of remotes is ordered with
|
- have the key. The list of remotes is ordered with
|
||||||
|
|
|
@ -218,7 +218,7 @@ finishedTransfer t (Just info)
|
||||||
| transferDirection t == Download =
|
| transferDirection t == Download =
|
||||||
whenM (liftAnnex $ inAnnex $ transferKey t) $ do
|
whenM (liftAnnex $ inAnnex $ transferKey t) $ do
|
||||||
dodrops False
|
dodrops False
|
||||||
queueTransfersMatching (/= transferUUID t)
|
void $ queueTransfersMatching (/= transferUUID t)
|
||||||
"newly received object"
|
"newly received object"
|
||||||
Later (transferKey t) (associatedFile info) Upload
|
Later (transferKey t) (associatedFile info) Upload
|
||||||
| otherwise = dodrops True
|
| otherwise = dodrops True
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue