From da8414b71a226ebdd055a8f88f5acb15c7771797 Mon Sep 17 00:00:00 2001 From: jacquarg Date: Mon, 5 Sep 2022 09:08:41 +0200 Subject: [PATCH] 5710-Update trackers list only when it has changes. --- build_list.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/build_list.js b/build_list.js index d1fb1cfa..6b986608 100644 --- a/build_list.js +++ b/build_list.js @@ -54,6 +54,11 @@ fetch(adawayUri) hostnames = createdLevel2Trackers(trackers, hostnames) console.log("Trackers list finished") }) +.then(toto => { + if (listHasNoChanges()) { + throw "No changes in trackers, abort updating." + } +}) .then(toto => { return printTrackers() }) @@ -147,6 +152,14 @@ function toLevel2Domain(hostname) { } } + +function listHasNoChanges() { + // Compare actual list with the builded one (without the createdAt field!) + const oldTrackers = require("./" + outputFile).trackers + return JSON.stringify(trackers) == JSON.stringify(oldTrackers) +} + + function printTrackers() { return JSON.stringify({ trackers: trackers, @@ -154,6 +167,8 @@ function printTrackers() { }) } + + function saveTrackersFile(trackersJson) { fs.writeFileSync(outputFile, trackersJson) } -- GitLab