From 19304cd1ae4e4ba4f6dcf4f1db14de1e4e70c250 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Mon, 10 Jan 2022 23:38:56 +0100 Subject: improve item list styling; add payload creation form; exend dialog mechanism --- common/indexeddb.js | 4 ++-- common/lock.js | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'common') diff --git a/common/indexeddb.js b/common/indexeddb.js index f9c407a..a18c9be 100644 --- a/common/indexeddb.js +++ b/common/indexeddb.js @@ -313,8 +313,8 @@ async function _save_items(resources, mappings, context) /* * Save given definition of a resource/mapping to IndexedDB. If the definition * (passed as `item`) references files that are not already present in - * IndexedDB, those files should be present as values of the `files_sha256` - * object with keys being of the form `sha256-`. + * IndexedDB, those files should be provided as values of the `files' object + * used to create the transaction context. * * context should be one returned from start_items_transaction() and should be * later passed to finalize_transaction() so that files depended on are added to diff --git a/common/lock.js b/common/lock.js index 8dd2f5b..f577481 100644 --- a/common/lock.js +++ b/common/lock.js @@ -68,9 +68,20 @@ function _lock(lock, cb) { #EXPORT lock => new Promise(resolve => _lock(lock, resolve)) AS lock +function try_lock(lock) +{ + if (lock.free) { + lock.free = false; + return true; + } + + return false; +} +#EXPORT try_lock + function unlock(lock) { if (lock.free) - throw new Error("Attempting to release a free lock"); + throw new Exception("Attempting to release a free lock"); if (lock.queue.length === 0) { lock.free = true; -- cgit v1.2.3