Add item hashes to every collection
This commit is contained in:
rodič
181164591d
revize
80ddc7960d
|
@ -184,8 +184,9 @@ class DeConf_Collection {
|
|||
}
|
||||
|
||||
const efIndex = await _tomlLoad(fn.join("/"));
|
||||
const hash = await _makeHash([this.type, this.id].join(":"));
|
||||
const data = {
|
||||
index: { id: this.id, ...efIndex },
|
||||
index: { id: this.id, hash, ...efIndex },
|
||||
};
|
||||
if (this.dir) {
|
||||
const syncDataFn = [this.dir, "data.json"].join("/");
|
||||
|
@ -228,7 +229,7 @@ class DeConf_Collection {
|
|||
if (await exists(fn)) {
|
||||
sp.photo = ["photos", "speakers", ffn].join("/");
|
||||
continue;
|
||||
};
|
||||
}
|
||||
await ensureDir(dir);
|
||||
const nameId = sp.id || sp.name.toLowerCase().replace(/ /g, "-");
|
||||
const photoFetch = await fetch(sp.photoUrl);
|
||||
|
@ -310,3 +311,11 @@ async function _jsonWrite(fn, data) {
|
|||
async function _jsonLoad(fn) {
|
||||
return JSON.parse(await Deno.readTextFile(fn));
|
||||
}
|
||||
|
||||
async function _makeHash(str) {
|
||||
return Array.from(
|
||||
new Uint8Array(
|
||||
await crypto.subtle.digest("SHA-256", (new TextEncoder()).encode(str)),
|
||||
),
|
||||
).map((b) => b.toString(16).padStart(2, "0")).join("");
|
||||
}
|
||||
|
|
|
@ -9,6 +9,9 @@ properties:
|
|||
type: string
|
||||
pattern: "^[a-z0-9-]+$"
|
||||
title: Benefit ID
|
||||
hash:
|
||||
type: string
|
||||
pattern: "^[a-f0-9]+$"
|
||||
name:
|
||||
type: string
|
||||
title: Name of Benefit
|
||||
|
|
|
@ -15,6 +15,9 @@ properties:
|
|||
type: string
|
||||
pattern: "^[a-z0-9-]+$"
|
||||
title: Event ID
|
||||
hash:
|
||||
type: string
|
||||
pattern: "^[a-f0-9]+$"
|
||||
name:
|
||||
type: string
|
||||
title: Name of event
|
||||
|
|
|
@ -9,6 +9,9 @@ properties:
|
|||
type: string
|
||||
pattern: "^[a-z0-9-]+$"
|
||||
title: ID
|
||||
hash:
|
||||
type: string
|
||||
pattern: "^[a-f0-9]+$"
|
||||
name:
|
||||
type: string
|
||||
title: Name
|
||||
|
|
|
@ -9,6 +9,9 @@ properties:
|
|||
type: string
|
||||
pattern: "^[a-z0-9-]+$"
|
||||
title: Event Union ID
|
||||
hash:
|
||||
type: string
|
||||
pattern: "^[a-f0-9]+$"
|
||||
name:
|
||||
type: string
|
||||
title: Name of Event Union
|
||||
|
|
Načítá se…
Odkázat v novém úkolu