fix IndexedDB directories not being deleted

master
Michele Guerini Rocco 2019-06-02 10:40:13 +02:00
parent 62953174b4
commit ff66f6705c
Signed by: rnhmjoj
GPG Key ID: 91BE884FBA4B591A
1 changed files with 7 additions and 4 deletions

11
Main.hs
View File

@ -82,16 +82,19 @@ deleteCookies domains = do
deleteData :: [Text] -> Action (Int, [Text])
deleteData whitelist = do
webengine <- asks webenginePath
appCache <- liftIO $ getDirectoryFiles (webengine </> "Application Cache")
indexedDB <- liftIO $ getDirectoryFiles (webengine </> "IndexedDB")
localStorage <- liftIO $ getDirectoryFiles (webengine </> "Local Storage")
appCache <- liftIO $ listDirectoryAbs (webengine </> "Application Cache")
indexedDB <- liftIO $ listDirectoryAbs (webengine </> "IndexedDB")
localStorage <- liftIO $ listDirectoryAbs (webengine </> "Local Storage")
let
entries = appCache ++ indexedDB ++ localStorage
badFiles = filterMaybe (fmap unlisted . domain) entries
badDomains = mapMaybe domain badFiles
liftIO $ mapM_ removeFile badFiles
liftIO $ mapM_ removePathForcibly badFiles
return (length badFiles, nub badDomains)
where
listDirectoryAbs :: FilePath -> IO [FilePath]
listDirectoryAbs dir = map (dir </>) <$> listDirectory dir
maybeToBool :: Maybe Bool -> Bool
maybeToBool Nothing = False
maybeToBool (Just x) = x