@h1r-ai/croche 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.workerd.js
CHANGED
package/dist/pal/file-lock.d.ts
CHANGED
|
@@ -38,8 +38,7 @@ export declare function generations(path: string): Promise<number[]>;
|
|
|
38
38
|
/** Record `generation` of `path`: 'absent' if it is gone, null if it cannot be read as one. */
|
|
39
39
|
export declare function lockRecord(path: string, generation: number): Promise<LockRecord | null | 'absent'>;
|
|
40
40
|
export type FileLock = {
|
|
41
|
-
/**
|
|
42
|
-
* `released`. */
|
|
41
|
+
/** Runs `released`, then publishes a `free` record above this owner's while it is still on top. */
|
|
43
42
|
release: () => Promise<void>;
|
|
44
43
|
/** The fence: throws (no code) unless this owner's record (generation and nonce) is still
|
|
45
44
|
* the one on top. */
|
package/dist/pal/file-lock.js
CHANGED
|
@@ -296,6 +296,7 @@ export async function acquireFileLock(path, released) {
|
|
|
296
296
|
};
|
|
297
297
|
const release = async () => {
|
|
298
298
|
held.delete(path);
|
|
299
|
+
released();
|
|
299
300
|
try {
|
|
300
301
|
const [top = 0] = await generations(path);
|
|
301
302
|
const found = top === generation ? await lockRecord(path, generation) : null;
|
|
@@ -304,7 +305,6 @@ export async function acquireFileLock(path, released) {
|
|
|
304
305
|
}
|
|
305
306
|
}
|
|
306
307
|
catch { /* the next opener checks the pid */ }
|
|
307
|
-
released();
|
|
308
308
|
};
|
|
309
309
|
return { release, verify };
|
|
310
310
|
}
|
package/dist/pal/file-storage.js
CHANGED
|
@@ -46,8 +46,15 @@ export class FileStorage {
|
|
|
46
46
|
if (owner !== undefined)
|
|
47
47
|
await this.held.get(owner).verify();
|
|
48
48
|
else
|
|
49
|
-
for (const lock of this.held
|
|
50
|
-
|
|
49
|
+
for (const [name, lock] of this.held) {
|
|
50
|
+
try {
|
|
51
|
+
await lock.verify();
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
if (this.held.get(name) === lock)
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
51
58
|
}
|
|
52
59
|
async get(dir, key) {
|
|
53
60
|
try {
|