From 343136536fa7839f592384e89c1e89995582fab0 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Sun, 5 Sep 2021 23:59:12 +0200 Subject: [PATCH] Fix issue #6 Avoid generating a large SQL query by making the patterns an ad-hoc table --- Main.hs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Main.hs b/Main.hs index bc75741..3e831d6 100644 --- a/Main.hs +++ b/Main.hs @@ -146,11 +146,17 @@ deleteQuotaOrigins = do n <- S.deleteFrom quotaOrigins (by whitelist) return (n, nub bad) where - -- check if x ∉ set - by set x = S.not_ . any_ . map (S.like (x ! #origin)) $ set + -- check if quota is not whitelisted + by whitelist quota = S.not_ (S.true `S.isIn` matches) + where + url = quota ! #origin + matches = do + pattern <- S.selectValues (map S.Only whitelist) + S.restrict (url `S.like` S.the pattern) + return S.true -- turns domains into patterns to match a url - pattern domain = S.text ("http%://%" <> domain <> "/") - any_ = foldl' (.||) S.false + pattern domain = "http%://%" <> domain <> "/" + -- | Deletes per-domain files under the IndexedDB directory