mirror of https://github.com/voidlizard/hbs2
RsTry2C5Gk-log-this-situation
This commit is contained in:
parent
0787a49ef3
commit
953b917c1a
|
@ -14,6 +14,8 @@ import HBS2.Prelude.Plated
|
||||||
import HBS2.Storage
|
import HBS2.Storage
|
||||||
import HBS2.Base58
|
import HBS2.Base58
|
||||||
|
|
||||||
|
import HBS2.System.Logger.Simple
|
||||||
|
|
||||||
import Control.Concurrent.Async
|
import Control.Concurrent.Async
|
||||||
import Control.Exception
|
import Control.Exception
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
|
@ -245,7 +247,9 @@ simpleGetChunkLazy s key off size = do
|
||||||
let action = do
|
let action = do
|
||||||
let fn = simpleBlockFileName s key
|
let fn = simpleBlockFileName s key
|
||||||
|
|
||||||
bs <- (Just <$> touchForRead s key) `catchAny` \e -> liftIO (print "CANT MMAP") >> (pure Nothing) -- FIXME: log this situation (file not found)
|
bs <- (Just <$> touchForRead s key) `catchAny` \_ -> do
|
||||||
|
err $ "simpleGetChunkLazy" <+> pretty key <+> pretty off <+> pretty size
|
||||||
|
pure Nothing
|
||||||
|
|
||||||
let result = BS.take (fromIntegral size) . BS.drop (fromIntegral off) <$> bs
|
let result = BS.take (fromIntegral size) . BS.drop (fromIntegral off) <$> bs
|
||||||
|
|
||||||
|
@ -287,6 +291,10 @@ simplePutBlockLazy doWait s lbs = do
|
||||||
|
|
||||||
if doWait then do
|
if doWait then do
|
||||||
ok <- atomically $ TBQ.readTBQueue waits
|
ok <- atomically $ TBQ.readTBQueue waits
|
||||||
|
|
||||||
|
unless ok do
|
||||||
|
err $ "simplePutBlockLazy" <+> pretty hash <+> pretty fn
|
||||||
|
|
||||||
pure $! if ok then Just hash else Nothing
|
pure $! if ok then Just hash else Nothing
|
||||||
else
|
else
|
||||||
pure $ Just hash
|
pure $ Just hash
|
||||||
|
@ -326,6 +334,9 @@ simpleWriteLinkRaw ss h lbs = do
|
||||||
r <- MaybeT $ putBlock ss lbs
|
r <- MaybeT $ putBlock ss lbs
|
||||||
MaybeT $ liftIO $ spawnAndWait ss $ do
|
MaybeT $ liftIO $ spawnAndWait ss $ do
|
||||||
BS.writeFile fnr (toByteString (AsBase58 r))
|
BS.writeFile fnr (toByteString (AsBase58 r))
|
||||||
|
`catchAny` \_ -> do
|
||||||
|
err $ "simpleWriteLinkRaw" <+> pretty h <+> pretty fnr
|
||||||
|
|
||||||
pure h
|
pure h
|
||||||
|
|
||||||
simpleWriteLinkRawRef :: forall h . ( IsSimpleStorageKey h
|
simpleWriteLinkRawRef :: forall h . ( IsSimpleStorageKey h
|
||||||
|
@ -341,6 +352,8 @@ simpleWriteLinkRawRef ss h ref = do
|
||||||
let fnr = simpleRefFileName ss h
|
let fnr = simpleRefFileName ss h
|
||||||
void $ spawnAndWait ss $ do
|
void $ spawnAndWait ss $ do
|
||||||
BS.writeFile fnr (toByteString (AsBase58 ref))
|
BS.writeFile fnr (toByteString (AsBase58 ref))
|
||||||
|
`catchAny` \_ -> do
|
||||||
|
err $ "simpleWriteLinkRawRef" <+> pretty h <+> pretty ref <+> pretty fnr
|
||||||
|
|
||||||
simpleReadLinkRaw :: IsKey h
|
simpleReadLinkRaw :: IsKey h
|
||||||
=> SimpleStorage h
|
=> SimpleStorage h
|
||||||
|
@ -351,7 +364,9 @@ simpleReadLinkRaw ss hash = do
|
||||||
let fn = simpleRefFileName ss hash
|
let fn = simpleRefFileName ss hash
|
||||||
rs <- spawnAndWait ss $ do
|
rs <- spawnAndWait ss $ do
|
||||||
-- FIXME: log-this-situation
|
-- FIXME: log-this-situation
|
||||||
(Just <$> LBS.readFile fn) `catchAny` const (pure Nothing)
|
(Just <$> LBS.readFile fn) `catchAny` \_ -> do
|
||||||
|
err $ "simpleReadLinkRaw" <+> pretty hash <+> pretty fn
|
||||||
|
pure Nothing
|
||||||
|
|
||||||
pure $ fromMaybe Nothing rs
|
pure $ fromMaybe Nothing rs
|
||||||
|
|
||||||
|
@ -369,7 +384,9 @@ simpleReadLinkVal ss hash = do
|
||||||
let fn = simpleRefFileName ss hash
|
let fn = simpleRefFileName ss hash
|
||||||
rs <- spawnAndWait ss $ do
|
rs <- spawnAndWait ss $ do
|
||||||
-- FIXME: log-this-situation
|
-- FIXME: log-this-situation
|
||||||
(Just <$> BS.readFile fn) `catchAny` \_ -> pure Nothing
|
(Just <$> BS.readFile fn) `catchAny` \_ -> do
|
||||||
|
err $ "simpleReadLinkVal" <+> pretty hash <+> pretty fn
|
||||||
|
pure Nothing
|
||||||
|
|
||||||
runMaybeT do
|
runMaybeT do
|
||||||
MaybeT . getBlock ss . unAsBase58 =<< MaybeT (pure (fromByteString =<< join rs))
|
MaybeT . getBlock ss . unAsBase58 =<< MaybeT (pure (fromByteString =<< join rs))
|
||||||
|
|
Loading…
Reference in New Issue