mirror of
https://github.com/Nezumi-2711/cloudflare-gateway-pihole-scripts.git
synced 2026-09-22 13:38:37 +00:00
remove existing lists before downloading
This commit is contained in:
+9
-1
@@ -1,3 +1,5 @@
|
|||||||
|
import { existsSync } from "fs";
|
||||||
|
import { unlink } from "fs/promises";
|
||||||
import { resolve } from "path";
|
import { resolve } from "path";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -15,7 +17,13 @@ const blocklistUrls = USER_DEFINED_BLOCKLIST_URLS || RECOMMENDED_BLOCKLIST_URLS;
|
|||||||
const listType = process.argv[2];
|
const listType = process.argv[2];
|
||||||
|
|
||||||
const downloadLists = async (filename, urls) => {
|
const downloadLists = async (filename, urls) => {
|
||||||
await downloadFiles(resolve(`./${filename}`), urls);
|
const filePath = resolve(`./${filename}`);
|
||||||
|
|
||||||
|
if (existsSync(filePath)) {
|
||||||
|
await unlink(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
await downloadFiles(filePath, urls);
|
||||||
console.log(
|
console.log(
|
||||||
`Done. The ${filename} file contains merged data from the following list(s):`
|
`Done. The ${filename} file contains merged data from the following list(s):`
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user