From 1c65dd5ca24052ccf9a92939eecd0966c9635c50 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Wed, 9 Feb 2022 17:09:13 +0100 Subject: adapt to changes in file path format From now on we assume Hydrilla serves file contents at 'file/sha256/' instead of 'file/sha256-'. With this commit we also stop using the "hash_key" property internally. --- html/payload_create.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'html/payload_create.js') diff --git a/html/payload_create.js b/html/payload_create.js index 8828809..7782299 100644 --- a/html/payload_create.js +++ b/html/payload_create.js @@ -45,7 +45,7 @@ #IMPORT common/indexeddb.js AS haketilodb #FROM html/DOM_helpers.js IMPORT clone_template -#FROM common/sha256.js IMPORT sha256 +#FROM common/sha256.js IMPORT sha256 AS compute_sha256 #FROM common/patterns.js IMPORT validate_normalize_url_pattern, \ patterns_doc_url @@ -94,7 +94,7 @@ function collect_form_data(form_ctx) const script = form_ctx.script.value; if (!script) throw "The 'script' field is required!"; - const hash_key = `sha256-${sha256(script)}`; + const sha256 = compute_sha256(script); const resource = { source_name: identifier, @@ -106,7 +106,7 @@ function collect_form_data(form_ctx) version: [1], description, dependencies: [], - scripts: [{file: "payload.js", hash_key}] + scripts: [{file: "payload.js", sha256}] }; const mapping = { @@ -121,7 +121,7 @@ function collect_form_data(form_ctx) payloads }; - return {identifier, resource, mapping, files: {[hash_key]: script}}; + return {identifier, resource, mapping, files_by_sha256: {[sha256]: script}}; } function clear_form(form_ctx) @@ -137,7 +137,8 @@ async function save_payload(saving) { const db = await haketilodb.get(); const tx_starter = haketilodb.start_items_transaction; - const tx_ctx = await tx_starter(["resource", "mapping"], saving.files); + const files = {sha256: saving.files_by_sha256}; + const tx_ctx = await tx_starter(["resource", "mapping"], files); for (const type of ["resource", "mapping"]) { if (!saving[`override_${type}`] && -- cgit v1.2.3