make leveldb handling more resilient
This commit is contained in:
parent
0ab048b795
commit
d0cd6cd456
10
Main.hs
10
Main.hs
@ -192,8 +192,11 @@ deleteLocalStorage = do
|
||||
whitelist <- asks whitelist
|
||||
let path = webengine </> "Local Storage" </> "leveldb"
|
||||
|
||||
dbIsOk <- liftIO $ D.doesFileExist (path </> "LOCK")
|
||||
when (not dbIsOk) (throwError "Database is missing or corrupted")
|
||||
|
||||
version <- withDB path (\db -> L.get db def "VERSION")
|
||||
when (version /= Just "1") (throwError "Unsupported schema version")
|
||||
when (version /= Just "1") (throwError "Database is empty or the schema unsupported")
|
||||
|
||||
withDB path $ \db -> do
|
||||
badDomains <- L.withIterator db def $ \i ->
|
||||
@ -234,8 +237,11 @@ deleteSessionStorage = do
|
||||
whitelist <- asks whitelist
|
||||
let path = webengine </> "Session Storage"
|
||||
|
||||
dbIsOk <- liftIO $ D.doesFileExist (path </> "LOCK")
|
||||
when (not dbIsOk) (throwError "Database is missing or corrupted")
|
||||
|
||||
version <- withDB path (\db -> L.get db def "version")
|
||||
when (version /= Just "1") (throwError "Unsupported schema version")
|
||||
when (version /= Just "1") (throwError "Database is empty or the schema unsupported")
|
||||
|
||||
withDB path $ \db -> do
|
||||
-- map of id -> isBad
|
||||
|
Loading…
Reference in New Issue
Block a user