This commit is contained in:
voidlizard 2024-12-08 08:16:30 +03:00
parent debe84f3ca
commit 3bd8422a6f
3 changed files with 18 additions and 15 deletions

View File

@ -783,7 +783,7 @@ export mref' r = connectedDo $ flip runContT pure do
packs <- atomically $ STM.flushTQueue out packs <- atomically $ STM.flushTQueue out
phashes <- catMaybes <$> withState (for parents selectCBlock) phashes <- catMaybes <$> withState (for parents (fmap (fmap snd) . selectCBlock))
let v = "hbs2-git 3.0 zstd" let v = "hbs2-git 3.0 zstd"
let pps = vcat $ mconcat $ for phashes $ \p -> ["p" <+> pretty p] let pps = vcat $ mconcat $ for phashes $ \p -> ["p" <+> pretty p]
@ -1256,16 +1256,15 @@ theDict = do
sto <- getStorage sto <- getStorage
let whatever cblock = do let whatever cblock = do
co <- listOnlyCommitsFromCBlock sto cblock -- co <- listOnlyCommitsFromCBlock sto cblock
e <- mapM gitObjectExists co <&> and -- e <- mapM gitObjectExists co <&> and
let continue = deep || not e || (only && cblock == cb0) -- let continue = deep || not e || (only && cblock == cb0)
debug $ "WHATEVER" <+> pretty e <+> pretty cblock <+> pretty co -- debug $ "WHATEVER" <+> pretty e <+> pretty cblock <+> pretty co
unless continue do -- unless continue do
debug $ "STOPPED" <+> pretty e <+> pretty cblock <+> pretty co -- debug $ "STOPPED" <+> pretty e <+> pretty cblock <+> pretty co
pure True
pure continue
flip runContT pure $ callCC \exit -> do flip runContT pure $ callCC \exit -> do

View File

@ -71,6 +71,7 @@ common shared-properties
, atomic-write , atomic-write
, bytestring , bytestring
, binary , binary
, bitvec
, containers , containers
, directory , directory
, exceptions , exceptions

View File

@ -17,6 +17,7 @@ import DBPipe.SQLite
import System.Directory import System.Directory
import Data.Maybe import Data.Maybe
import Data.Word
import Text.InterpolatedString.Perl6 (qc) import Text.InterpolatedString.Perl6 (qc)
@ -44,9 +45,10 @@ evolveState = do
ddl [qc| ddl [qc|
create table if not exists create table if not exists
cblock cblock
( kommit text not null ( id integer primary key autoincrement
, kommit text not null
, cblock text not null , cblock text not null
, primary key (kommit, cblock) , unique (kommit, cblock)
) )
|] |]
@ -74,16 +76,17 @@ insertCBlock co cblk = do
insert [qc| insert [qc|
insert into cblock (kommit, cblock) values(?,?) insert into cblock (kommit, cblock) values(?,?)
on conflict (kommit,cblock) do update set cblock = excluded.cblock on conflict (kommit,cblock) do update set cblock = excluded.cblock
on conflict (id) do update set kommit = excluded.kommit
, cblock = excluded.cblock
|] (co, cblk) |] (co, cblk)
selectCBlock :: MonadIO m => GitHash -> DBPipeM m (Maybe HashRef) selectCBlock :: MonadIO m => GitHash -> DBPipeM m (Maybe (Word32, HashRef))
selectCBlock gh = do selectCBlock gh = do
select [qc|select cblock from cblock where kommit = ? limit 1|] (Only gh) select [qc|select id, cblock from cblock where kommit = ? limit 1|] (Only gh)
<&> listToMaybe . fmap fromOnly <&> listToMaybe
selectCommitsByCBlock :: MonadIO m => HashRef -> DBPipeM m [GitHash] selectCommitsByCBlock :: MonadIO m => HashRef -> DBPipeM m [GitHash]
selectCommitsByCBlock cb = do selectCommitsByCBlock cb = do
select [qc|select kommit from cblock where cblock = ? limit 1|] (Only cb) select [qc|select kommit from cblock where cblock = ? limit 1|] (Only cb)
<&> fmap fromOnly <&> fmap fromOnly