bugfix (missed objects)

This commit is contained in:
Dmitry Zuikov 2023-10-06 17:16:40 +03:00
parent 0c738902b0
commit 99f0b4a7ad
2 changed files with 16 additions and 13 deletions

View File

@ -107,18 +107,6 @@ loop args = do
warn "trying to init reference --- may be it's ours"
liftIO $ runApp WithLog (runExport Nothing ref)
refs <- withDB db stateGetActualRefs
let heads = [ h | h@GitHash{} <- universeBi refs ]
missed <- try (mapM (gitReadObject Nothing) heads) <&> either (\(_::SomeException) -> True) (const False)
let force = missed || List.null heads
debug $ "THIS MIGHT BE CLONE!" <+> pretty force
-- sync state first
traceTime "TIMING: importRefLogNew" $ importRefLogNew force ref
refsNew <- withDB db stateGetActualRefs
let possibleHead = listToMaybe $ List.take 1 $ List.sortOn guessHead (fmap fst refsNew)
@ -190,6 +178,18 @@ loop args = do
other -> die $ show other
refs <- withDB db stateGetActualRefs
let heads = [ h | h@GitHash{} <- universeBi refs ]
missed <- try (mapM (gitReadObject Nothing) heads) <&> either (\(_::SomeException) -> True) (const False)
let force = missed || List.null heads
when force do
-- sync state first
traceTime "TIMING: importRefLogNew" $ importRefLogNew True ref
shutUp
where

View File

@ -31,6 +31,8 @@ import Control.Concurrent.STM
import Data.Graph (graphFromEdges, topSort)
import Lens.Micro.Platform
import System.IO (stderr)
-- FIXME: move-orphans-to-separate-module
instance ToField Cookie where
@ -267,7 +269,7 @@ readOrCreateCookie = do
liftIO $ Text.writeFile cfn (fromCookie cookie)
pure cookie
else do
let cookie = Cookie (fromString cf)
let cookie@(Cookie co) = Cookie (fromString cf)
statePutCookie cookie
pure cookie
@ -421,6 +423,7 @@ statePutTranImported :: MonadIO m => HashRef -> DB m ()
statePutTranImported h = do
conn <- stateConnection
cookie <- asks (view dbCookie)
debug $ "statePutTranImported" <+> pretty h <+> viaShow cookie
liftIO $ execute conn [qc|
insert into tranimported (hash, cookie) values(?, ?)
on conflict (hash, cookie) do nothing