mirror of https://github.com/voidlizard/hbs2
wip, tombs count calculation
This commit is contained in:
parent
5ec77f6ab5
commit
a1d6916ed9
2
Makefile
2
Makefile
|
@ -71,7 +71,7 @@ symlinks: $(BIN_DIR)
|
||||||
> done
|
> done
|
||||||
> ln -sfn ../hbs2-git3/bf6/git-hbs2 bin/git-hbs2
|
> ln -sfn ../hbs2-git3/bf6/git-hbs2 bin/git-hbs2
|
||||||
> ln -sfn ../hbs2-git3/bf6/hbs2-git bin/hbs2-git
|
> ln -sfn ../hbs2-git3/bf6/hbs2-git bin/hbs2-git
|
||||||
> ln -sfn ../bf6/hbs23 bin/hbs23
|
> ln -sfn ../bf6/hbs2 bin/hbs2
|
||||||
|
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
|
|
|
@ -1252,9 +1252,14 @@ ncqFsckOne :: MonadUnliftIO m => FilePath -> m [NCQFsckIssue]
|
||||||
ncqFsckOne fp = do
|
ncqFsckOne fp = do
|
||||||
mmaped <- liftIO $ mmapFileByteString fp Nothing
|
mmaped <- liftIO $ mmapFileByteString fp Nothing
|
||||||
|
|
||||||
|
notice $ "file" <+> pretty (takeFileName fp) <+> pretty (BS.length mmaped)
|
||||||
|
|
||||||
toff <- newTVarIO 0
|
toff <- newTVarIO 0
|
||||||
issuesQ <- newTQueueIO
|
issuesQ <- newTQueueIO
|
||||||
|
|
||||||
|
ttombs <- newTVarIO 0
|
||||||
|
ttotal <- newTVarIO 0
|
||||||
|
|
||||||
let
|
let
|
||||||
emit :: forall m . MonadIO m => NCQFsckIssue -> m ()
|
emit :: forall m . MonadIO m => NCQFsckIssue -> m ()
|
||||||
emit = atomically . writeTQueue issuesQ
|
emit = atomically . writeTQueue issuesQ
|
||||||
|
@ -1271,6 +1276,10 @@ ncqFsckOne fp = do
|
||||||
| prefix == ncqTombPrefix -> (True, Just T)
|
| prefix == ncqTombPrefix -> (True, Just T)
|
||||||
| otherwise -> (False, Nothing)
|
| otherwise -> (False, Nothing)
|
||||||
|
|
||||||
|
atomically do
|
||||||
|
when (prefix == ncqTombPrefix) $ modifyTVar ttombs succ
|
||||||
|
modifyTVar ttotal succ
|
||||||
|
|
||||||
let contentOk = case pt of
|
let contentOk = case pt of
|
||||||
Just B -> hash == hashObject @HbSync rest2
|
Just B -> hash == hashObject @HbSync rest2
|
||||||
_ -> True
|
_ -> True
|
||||||
|
@ -1294,6 +1303,12 @@ ncqFsckOne fp = do
|
||||||
unless (fromIntegral (BS.length mmaped) == lastOff) do
|
unless (fromIntegral (BS.length mmaped) == lastOff) do
|
||||||
emit (NCQFsckIssue fp lastOff FsckInvalidFileSize)
|
emit (NCQFsckIssue fp lastOff FsckInvalidFileSize)
|
||||||
|
|
||||||
|
tombs <- readTVarIO ttombs <&> realToFrac
|
||||||
|
total <- readTVarIO ttotal <&> realToFrac
|
||||||
|
let ttr = if total /= 0 then tombs / total else 0 :: Fixed E3
|
||||||
|
|
||||||
|
notice $ "tombs/total" <+> pretty ttr <+> pretty tombs <> "/" <> pretty total
|
||||||
|
|
||||||
atomically $ STM.flushTQueue issuesQ
|
atomically $ STM.flushTQueue issuesQ
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ common shared-properties
|
||||||
, TypeFamilies
|
, TypeFamilies
|
||||||
|
|
||||||
|
|
||||||
executable hbs2
|
executable hbs2-obsolete
|
||||||
import: shared-properties
|
import: shared-properties
|
||||||
main-is: Main.hs
|
main-is: Main.hs
|
||||||
other-modules:
|
other-modules:
|
||||||
|
|
Loading…
Reference in New Issue