From 5e374b68cdb70af9d3dbd7cba16d47b115507a0a Mon Sep 17 00:00:00 2001 From: voidlizard Date: Mon, 30 Dec 2024 23:14:59 +0300 Subject: [PATCH] argh --- hbs2-git3/app/Main.hs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/hbs2-git3/app/Main.hs b/hbs2-git3/app/Main.hs index 6431b662..c4b4b65c 100644 --- a/hbs2-git3/app/Main.hs +++ b/hbs2-git3/app/Main.hs @@ -908,6 +908,8 @@ theDict = do >>= orThrow SomeReadLogError <&> GitHash . LBS.toStrict + void $ readBytesMaybe 32 + lift $ S.yield hash go (succ n) @@ -915,7 +917,7 @@ theDict = do for_ hashes $ \h -> do -- found <- binSearchBS 24 (BS.take 20 . BS.drop 4) ( show . pretty . GitHash ) (coerce h) file - found <- liftIO $ binarySearchBS 24 (BS.take 20 . BS.drop 4) (coerce h) file + found <- liftIO $ binarySearchBS 56 (BS.take 20 . BS.drop 4) (coerce h) file liftIO $ print $ pretty h <+> pretty (isJust found) _ -> throwIO (BadFormException @C nil) @@ -933,7 +935,7 @@ theDict = do & orThrowUser "no index specified" file <- liftIO $ mmapFileByteString idxName Nothing - r <- liftIO $ binarySearchBS 24 (BS.take 20 . BS.drop 4) (coerce hash) file + r <- liftIO $ binarySearchBS 56 (BS.take 20 . BS.drop 4) (coerce hash) file liftIO $ print $ pretty r @@ -1122,11 +1124,13 @@ theDict = do [ StringLike f ] -> lift do bs <- liftIO $ mmapFileByteString f Nothing scanBS bs $ \segment -> do - let (sha1,blake) = BS.splitAt 20 segment - & over _1 (coerce @_ @GitHash) - & over _2 (coerce @_ @HashRef) + none + -- let (sha1,blake) = BS.splitAt 20 segment + -- & over _1 (coerce @_ @GitHash) + -- & over _2 (coerce @_ @HashRef) - liftIO $ hPrint stdout $ pretty sha1 <+> pretty blake + -- notice $ pretty sha1 <+> pretty blake + liftIO $ print $ pretty "okay" _ -> throwIO (BadFormException @C nil) @@ -1600,6 +1604,8 @@ linearSearchLBS hash lbs = do >>= orThrow SomeReadLogError <&> LBS.toStrict + void $ readBytesMaybe 32 + case (compare hash1 (coerce hash)) of EQ -> lift $ S.yield n _ -> go (succ n)