This commit is contained in:
Dmitry Zuikov 2024-09-11 13:24:10 +03:00
parent 03377da1b5
commit 08c61d9000
2 changed files with 14 additions and 9 deletions

View File

@ -365,11 +365,10 @@ refchanExport dry = do
-- только такие элементы, которые реально отсутствуют
-- в рефчане
what <- select_ @_ @FixmeExported [qc|
select distinct o,0,k,cast (v as text)
select distinct o,w,k,cast (v as text)
from object obj
where not exists (select null from scanned where hash = obj.nonce)
or obj.nonce is null
order by o, k, v
order by o, k, v, w
|]
let chu = chunksOf 10000 what
@ -415,9 +414,11 @@ refchanImport = do
-- TODO: assume-huge-list
-- scanned <- listAllScanned
let isScanned = selectIsAlreadyScanned
let goodToGo x = do
here <- selectIsAlreadyScanned x
pure $ not here
walkRefChanTx @UNIX isScanned chan $ \txh u -> do
walkRefChanTx @UNIX goodToGo chan $ \txh u -> do
case u of
@ -436,6 +437,8 @@ refchanImport = do
scanned <- lift $ selectIsAlreadyScanned href
-- notice $ yellow "SCANNED" <+> pretty scanned
if scanned then do
atx <- readTVarIO accepts <&> fromMaybe mempty . HM.lookup txh
lift $ withState $ transactional do
@ -453,7 +456,6 @@ refchanImport = do
& toMPlus
for_ exported $ \exported -> do
unless scanned do
atomically $ writeTQueue tq (txh, orig, href, exported)
imported <- atomically $ flushTQueue tq

View File

@ -461,14 +461,17 @@ insertFixmeExported h item = do
on conflict (o, k)
do update set
v = case
when excluded.w > object.w and (excluded.v <> object.v) then excluded.v
when excluded.w > object.w then excluded.v
else object.v
end,
w = case
when excluded.w > object.w and (excluded.v <> object.v) then excluded.w
when excluded.w > object.w then excluded.w
else object.w
end,
nonce = excluded.nonce
nonce = case
when excluded.w > object.w then excluded.nonce
else object.nonce
end
|]
insert sql (WithNonce h item)