mirror of https://github.com/voidlizard/hbs2
wip-5
This commit is contained in:
parent
d51d947e56
commit
fce2906adc
|
@ -409,6 +409,7 @@ unpackPEntry = \case
|
||||||
data ExportState =
|
data ExportState =
|
||||||
ExportGetCommit
|
ExportGetCommit
|
||||||
| ExportCheck
|
| ExportCheck
|
||||||
|
| ExportStart
|
||||||
|
|
||||||
theDict :: forall m . ( HBS2GitPerks m
|
theDict :: forall m . ( HBS2GitPerks m
|
||||||
, HasClientAPI PeerAPI UNIX m
|
, HasClientAPI PeerAPI UNIX m
|
||||||
|
@ -529,6 +530,10 @@ theDict = do
|
||||||
|
|
||||||
flip fix ExportGetCommit $ \next -> \case
|
flip fix ExportGetCommit $ \next -> \case
|
||||||
|
|
||||||
|
ExportStart -> do
|
||||||
|
here <- lift $ withState $ selectGitPack r <&> isJust
|
||||||
|
if here then next ExportCheck else next ExportGetCommit
|
||||||
|
|
||||||
ExportGetCommit -> do
|
ExportGetCommit -> do
|
||||||
|
|
||||||
co' <- atomically $ stateTVar q $ HPSQ.alterMin \case
|
co' <- atomically $ stateTVar q $ HPSQ.alterMin \case
|
||||||
|
@ -542,10 +547,9 @@ theDict = do
|
||||||
debug $ "Process commit" <+> pretty co
|
debug $ "Process commit" <+> pretty co
|
||||||
debug $ "check-pack-for" <+> pretty prio <+> pretty co
|
debug $ "check-pack-for" <+> pretty prio <+> pretty co
|
||||||
|
|
||||||
inDb <- lift $ withState (selectGitPack co) <&> isJust
|
|
||||||
isDone <- readTVarIO done <&> HS.member co
|
isDone <- readTVarIO done <&> HS.member co
|
||||||
|
|
||||||
let already = isDone || inDb
|
let already = isDone
|
||||||
|
|
||||||
if already
|
if already
|
||||||
then next ExportGetCommit
|
then next ExportGetCommit
|
||||||
|
@ -556,9 +560,10 @@ theDict = do
|
||||||
parents <- gitReadCommitParents bs
|
parents <- gitReadCommitParents bs
|
||||||
|
|
||||||
n <- for (zip [1..] parents) $ \(i,gh) -> do
|
n <- for (zip [1..] parents) $ \(i,gh) -> do
|
||||||
|
here <- lift $ withState $ selectGitPack gh <&> isJust
|
||||||
atomically do
|
atomically do
|
||||||
pdone <- readTVar done <&> HS.member gh
|
pdone <- readTVar done <&> HS.member gh
|
||||||
if pdone then do
|
if pdone || here then do
|
||||||
pure 0
|
pure 0
|
||||||
else do
|
else do
|
||||||
modifyTVar q (HPSQ.insert gh (prio-i) ())
|
modifyTVar q (HPSQ.insert gh (prio-i) ())
|
||||||
|
|
Loading…
Reference in New Issue