From 813abb0e2d0a934a4866c7125e6f5a763e589422 Mon Sep 17 00:00:00 2001 From: zefie Date: Mon, 14 Jul 2025 18:13:45 -0400 Subject: [PATCH] switch from sync.js to DownloadScript.tmpl --- .../wtv-disk/content/DownloadScreen.tmpl.js | 36 ++++++- .../includes/ServiceVault/wtv-disk/sync.js | 1 - .../includes/classes/WTVDisk.js | 98 ------------------- 3 files changed, 35 insertions(+), 100 deletions(-) diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/content/DownloadScreen.tmpl.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/content/DownloadScreen.tmpl.js index 07200197..7a772b5f 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/content/DownloadScreen.tmpl.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/content/DownloadScreen.tmpl.js @@ -4,6 +4,40 @@ var minisrv_service_file = true; headers = `200 OK Content-Type: text/html wtv-expire: wtv-disk:/content/DownloadScreen.tmpl` +var content_dir = "content/" +var diskmap_dir = content_dir + "diskmaps/"; +var diskmap = request_headers.query[wtvshared.getCaseInsensitiveKey("DiskMap", request_headers.query)]; +var diskmap_json_file = null; +Object.keys(service_vaults).forEach(function (g) { + if (diskmap_json_file != null) return; + diskmap_json_file = service_vaults[g] + "/" + service_name + "/" + diskmap_dir + diskmap + ".json"; + if (!fs.existsSync(diskmap_json_file)) diskmap_json_file = null; +}); +var diskmap_data = JSON.parse(fs.readFileSync(diskmap_json_file).toString()); +if (!diskmap_data[request_headers.query.group]) { + throw ("Invalid diskmap data (group does not match)"); +} +diskmap_data = diskmap_data[request_headers.query.group]; +var message = request_headers.query.message || diskmap_data.message || "Retrieving files..."; +var main_message = request_headers.query.main_message || diskmap_data.main_message || "Your receiver is downloading files."; +var success_url = request_headers.query.success_url || diskmap_data.success_url || null; +var fail_url = request_headers.query.fail_url || diskmap_data.fail_url || null; + +if (success_url === null) success_url = new clientShowAlert({ + 'image': this.minisrv_config.config.service_logo, + 'message': "Download successful!", + 'buttonlabel1': "Okay", + 'buttonaction1': "client:goback", + 'noback': true, +}).getURL(); + +if (fail_url === null) fail_url = new clientShowAlert({ + 'image': this.minisrv_config.config.service_logo, + 'message': "Download failed...", + 'buttonlabel1': "Okay", + 'buttonaction1': "client:goback", + 'noback': true, +}).getURL(); data = ` @@ -16,7 +50,7 @@ if (!request_headers.query.group) data += `&root=file://Disk/Browser/`; else data += `&group=${request_headers.query.group}`; data += `&message=Retrieving Files..." > - + Retrieving Files diff --git a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/sync.js b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/sync.js index 4c860168..7292ec52 100644 --- a/zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/sync.js +++ b/zefie_wtvp_minisrv/includes/ServiceVault/wtv-disk/sync.js @@ -321,7 +321,6 @@ if (request_headers['wtv-request-type'] == 'download') { Object.keys(service_vaults).forEach(function (g) { if (diskmap_json_file != null) return; diskmap_json_file = service_vaults[g] + "/" + service_name + "/" + diskmap_dir + diskmap + ".json"; - console.log("Checking diskmap file: " + diskmap_json_file); if (!fs.existsSync(diskmap_json_file)) diskmap_json_file = null; }); var diskmap_data = JSON.parse(fs.readFileSync(diskmap_json_file).toString()); diff --git a/zefie_wtvp_minisrv/includes/classes/WTVDisk.js b/zefie_wtvp_minisrv/includes/classes/WTVDisk.js index 1755cdf2..5821bd45 100644 --- a/zefie_wtvp_minisrv/includes/classes/WTVDisk.js +++ b/zefie_wtvp_minisrv/includes/classes/WTVDisk.js @@ -254,104 +254,6 @@ class WTVDownloadList { this.deleteGroup(group + "-UPDATE"); this.delete(path + ".GROUP-UPDATE/"); } - - /** - * Generates the Download page - * @param {object} minisrv_config minisrv config object - * @param {string} title Page title - * @param {string} group - * @param {string|null} diskmap - * @param {string|null} main_message Message displayed in the center of the page - * @param {string|null} message Initial progress bar message - * @param {boolean|null} force_update Force this update even if the client reports the files are synced - * @param {string|null} success_url Where the client goes when the process succeeds - * @param {string|null} fail_url Where the client goes when the process fails. - * @param {string|null} url Use your own URL for client:fetch?source= instead of our generated one - * @returns {string} HTML Download Page - */ - getSyncPage(title, group, diskmap = null, main_message = null, message = null, force_update = null, dont_delete_files = null, success_url = null, fail_url = null, url = null) { - // Begin Set defaults - if (main_message === null) main_message = "Your receiver is downloading files."; - - if (message === null) message = "Retrieving files"; - - if (force_update === null) force_update = false; - - if (url === null) url = this.service_name + ":/sync?diskmap=" + escape(diskmap); - - if (force_update) url += "&force=" + force_update; - if (dont_delete_files) url += "&dont_delete_files=" + dont_delete_files; - - if (success_url === null) success_url = new this.clientShowAlert({ - 'image': this.minisrv_config.config.service_logo, - 'message': "Download successful!", - 'buttonlabel1': "Okay", - 'buttonaction1': "client:goback", - 'noback': true, - }).getURL(); - - if (fail_url === null) fail_url = new this.clientShowAlert({ - 'image': this.minisrv_config.config.service_logo, - 'message': "Download failed...", - 'buttonlabel1': "Okay", - 'buttonaction1': "client:goback", - 'noback': true, - }).getURL(); - // End set defaults - return ` - - - - ${title} - - - - - - - -
- - - - - - -
- ${message} -
-
-
-
- - - -
- - - ${main_message} -

This may take a while. - -

- -

- - - - -
-
- - - -` - } - } module.exports = WTVDownloadList; \ No newline at end of file