Skip to content

Commit fac9a43

Browse files
stevensJourneyrhashimotoshoestringrdependabot[bot]
authored
Test update (#54)
* Update issue templates * Replace Facade Proxy with handwritten proxy. (rhashimoto#285) * Replace Proxy with handwritten proxy for jRead/jWrite buffers. * Replace Proxy with handwritten proxy for VFS return data. --------- Co-authored-by: Roy Hashimoto <[email protected]> * Use non-CAPTCHA SQLite download URL. (rhashimoto#289) * Use non-CAPTCHA SQLite download URL. * Use consistent Makefile variable bracing. --------- Co-authored-by: Roy Hashimoto <[email protected]> * Fix WebLocksMixin state initialization. (rhashimoto#293) * Fix WebLocksMixin state initialization. * Don't fetch state in WebLocksMixin file control unnecessarily. * Minor fixes. --------- Co-authored-by: Roy Hashimoto <[email protected]> * Bump package version. * Bump brace-expansion from 1.1.11 to 1.1.12 Bumps [brace-expansion](https://github.com/juliangruber/brace-expansion) from 1.1.11 to 1.1.12. - [Release notes](https://github.com/juliangruber/brace-expansion/releases) - [Commits](juliangruber/brace-expansion@1.1.11...v1.1.12) --- updated-dependencies: - dependency-name: brace-expansion dependency-version: 1.1.12 dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> * Bump koa from 2.16.1 to 2.16.3 Bumps [koa](https://github.com/koajs/koa) from 2.16.1 to 2.16.3. - [Release notes](https://github.com/koajs/koa/releases) - [Changelog](https://github.com/koajs/koa/blob/master/History.md) - [Commits](koajs/koa@v2.16.1...v2.16.3) --- updated-dependencies: - dependency-name: koa dependency-version: 2.16.3 dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> * Bump tar-fs from 3.0.9 to 3.1.1 Bumps [tar-fs](https://github.com/mafintosh/tar-fs) from 3.0.9 to 3.1.1. - [Commits](mafintosh/tar-fs@v3.0.9...v3.1.1) --- updated-dependencies: - dependency-name: tar-fs dependency-version: 3.1.1 dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> * add changeset --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Roy Hashimoto <[email protected]> Co-authored-by: Roy Hashimoto <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 1290c3d commit fac9a43

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

.changeset/spicy-ties-sing.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@journeyapps/wa-sqlite': patch
3+
---
4+
5+
Update upstream to [v1.0.9](https://github.com/rhashimoto/wa-sqlite/releases/tag/v1.0.9)

src/WebLocksMixin.js

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,7 @@ export const WebLocksMixin = superclass => class extends superclass {
4848
*/
4949
async jLock(fileId, lockType) {
5050
try {
51-
// Create state on first lock.
52-
if (!this.#mapIdToState.has(fileId)) {
53-
const name = this.getFilename(fileId);
54-
const state = {
55-
baseName: name,
56-
type: VFS.SQLITE_LOCK_NONE,
57-
writeHint: false
58-
};
59-
this.#mapIdToState.set(fileId, state);
60-
}
61-
62-
const lockState = this.#mapIdToState.get(fileId);
51+
const lockState = this.#getLockState(fileId);
6352
if (lockType <= lockState.type) return VFS.SQLITE_OK;
6453

6554
switch (this.#options.lockPolicy) {
@@ -82,10 +71,8 @@ export const WebLocksMixin = superclass => class extends superclass {
8271
*/
8372
async jUnlock(fileId, lockType) {
8473
try {
85-
// SQLite can call xUnlock() without ever calling xLock() so
86-
// the state may not exist.
87-
const lockState = this.#mapIdToState.get(fileId);
88-
if (!(lockType < lockState?.type)) return VFS.SQLITE_OK;
74+
const lockState = this.#getLockState(fileId);
75+
if (!(lockType < lockState.type)) return VFS.SQLITE_OK;
8976

9077
switch (this.#options.lockPolicy) {
9178
case 'exclusive':
@@ -107,7 +94,7 @@ export const WebLocksMixin = superclass => class extends superclass {
10794
*/
10895
async jCheckReservedLock(fileId, pResOut) {
10996
try {
110-
const lockState = this.#mapIdToState.get(fileId);
97+
const lockState = this.#getLockState(fileId);
11198
switch (this.#options.lockPolicy) {
11299
case 'exclusive':
113100
return this.#checkReservedExclusive(lockState, pResOut);
@@ -130,19 +117,29 @@ export const WebLocksMixin = superclass => class extends superclass {
130117
* @returns {number|Promise<number>}
131118
*/
132119
jFileControl(fileId, op, pArg) {
133-
const lockState = this.#mapIdToState.get(fileId) ??
134-
(() => {
135-
// Call jLock() to create the lock state.
136-
this.jLock(fileId, VFS.SQLITE_LOCK_NONE);
137-
return this.#mapIdToState.get(fileId);
138-
})();
139120
if (op === WebLocksMixin.WRITE_HINT_OP_CODE &&
140121
this.#options.lockPolicy === 'shared+hint'){
122+
const lockState = this.#getLockState(fileId);
141123
lockState.writeHint = true;
142124
}
143125
return VFS.SQLITE_NOTFOUND;
144126
}
145127

128+
#getLockState(fileId) {
129+
let lockState = this.#mapIdToState.get(fileId);
130+
if (!lockState) {
131+
// The state doesn't exist yet so create it.
132+
const name = this.getFilename(fileId);
133+
lockState = {
134+
baseName: name,
135+
type: VFS.SQLITE_LOCK_NONE,
136+
writeHint: false
137+
};
138+
this.#mapIdToState.set(fileId, lockState);
139+
}
140+
return lockState
141+
}
142+
146143
/**
147144
* @param {LockState} lockState
148145
* @param {number} lockType

0 commit comments

Comments
 (0)