Skip to content

Commit

Permalink
Bugfix: only use cache with no additional blocklists
Browse files Browse the repository at this point in the history
  • Loading branch information
th-ch committed Dec 6, 2020
1 parent 3022fac commit 467171a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "youtube-music",
"productName": "YouTube Music",
"version": "1.7.1",
"version": "1.7.2",
"description": "YouTube Music Desktop App - including custom plugins",
"license": "MIT",
"repository": "th-ch/youtube-music",
Expand Down
22 changes: 10 additions & 12 deletions plugins/adblocker/blocker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { existsSync, promises, unlinkSync } = require("fs"); // used for caching
const { promises } = require("fs"); // used for caching
const path = require("path");

const { ElectronBlocker } = require("@cliqz/adblocker-electron");
Expand All @@ -13,17 +13,15 @@ const loadAdBlockerEngine = (
cache = true,
additionalBlockLists = []
) => {
const adBlockerCache = path.resolve(__dirname, "ad-blocker-engine.bin");
if (!cache && existsSync(adBlockerCache)) {
unlinkSync(adBlockerCache);
}
const cachingOptions = cache
? {
path: adBlockerCache,
read: promises.readFile,
write: promises.writeFile,
}
: undefined;
// Only use cache if no additional blocklists are passed
const cachingOptions =
cache && additionalBlockLists.length === 0
? {
path: path.resolve(__dirname, "ad-blocker-engine.bin"),
read: promises.readFile,
write: promises.writeFile,
}
: undefined;

ElectronBlocker.fromLists(
fetch,
Expand Down

0 comments on commit 467171a

Please sign in to comment.