diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/indexeddb.js | 4 | ||||
-rw-r--r-- | common/lock.js | 13 |
2 files changed, 14 insertions, 3 deletions
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-<file's-sha256-sum>`. + * 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; |