mirror of https://github.com/voidlizard/hbs2
wip. Better wait. Uses the probe Download.wip ...
instead of sqlite query (RpcDownloadList)
This commit is contained in:
parent
a240bc23f0
commit
dcd13663d9
|
@ -194,7 +194,7 @@ main = flip runContT pure do
|
|||
|
||||
url <- case cli of
|
||||
[ ListVal [_, RepoURL x ] ] -> do
|
||||
notice $ "FUCKING REMOTE" <+> pretty (AsBase58 x)
|
||||
notice $ "git remote ref set:" <+> green (pretty (AsBase58 x))
|
||||
setGitRepoKey x
|
||||
pure $ Just x
|
||||
|
||||
|
|
|
@ -113,6 +113,8 @@ data ImportStage =
|
|||
| ImportWait (Maybe Int) ImportStage
|
||||
| ImportDone (Maybe HashRef)
|
||||
|
||||
{- HLINT ignore "Functor law" -}
|
||||
|
||||
importGitRefLog :: forall m . ( HBS2GitPerks m
|
||||
-- , HasStorage m
|
||||
-- , HasClientAPI PeerAPI UNIX m
|
||||
|
@ -145,16 +147,20 @@ importGitRefLog = withStateDo $ ask >>= \case
|
|||
|
||||
ImportWait d next -> do
|
||||
|
||||
down <- callRpcWaitMay @RpcDownloadList (TimeoutSec 1) peerAPI ()
|
||||
>>= orThrow RpcTimeout
|
||||
<&> fromIntegral . L.length
|
||||
pause @'Seconds 1.15
|
||||
|
||||
down <- callRpcWaitRetry @RpcGetProbes (TimeoutSec 1) 3 peerAPI ()
|
||||
>>= orThrow RpcTimeout
|
||||
<&> maybe 0 fromIntegral . headMay . mapMaybe \case
|
||||
ProbeSnapshotElement "Download.wip" n -> Just n
|
||||
_ -> Nothing
|
||||
|
||||
notice $ "wait some time..." <+> parens (pretty down)
|
||||
|
||||
case d of
|
||||
Just n | down < n || down == 0 -> again next
|
||||
Just n | down /= n || down == 0 -> again next
|
||||
|
||||
_ -> pause @'Seconds 3 >> again (ImportWait (Just down) next)
|
||||
_ -> pause @'Seconds 2.85 >> again (ImportWait (Just down) next)
|
||||
|
||||
ImportStart -> do
|
||||
|
||||
|
|
|
@ -650,7 +650,7 @@ downloadDispatcher probe brains env = do
|
|||
|
||||
dupes <- newTVarIO ( mempty :: HashMap HashRef Int )
|
||||
|
||||
ContT $ withAsync $ forever $ pause @'Seconds 10 >> do
|
||||
ContT $ withAsync $ forever $ pause @'Seconds 2 >> do
|
||||
acceptReport probe =<< S.toList_ do
|
||||
wip <- readTVarIO wip <&> HM.size
|
||||
pn <- readTVarIO pts <&> HM.size
|
||||
|
|
Loading…
Reference in New Issue