@tinycloud/operations 0.4.0-beta.13 → 0.4.0-beta.14
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/coverage.json +6 -0
- package/dist/artifacts.cjs +9 -3
- package/dist/artifacts.cjs.map +1 -1
- package/dist/artifacts.js +9 -3
- package/dist/artifacts.js.map +1 -1
- package/dist/cli-runtime.cjs +9 -3
- package/dist/cli-runtime.cjs.map +1 -1
- package/dist/cli-runtime.js +9 -3
- package/dist/cli-runtime.js.map +1 -1
- package/dist/delegation-binding.cjs +9 -3
- package/dist/delegation-binding.cjs.map +1 -1
- package/dist/delegation-binding.js +9 -3
- package/dist/delegation-binding.js.map +1 -1
- package/dist/index.cjs +9 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/dist/profile.cjs.map +1 -1
- package/dist/profile.js.map +1 -1
- package/dist/state.cjs +9 -3
- package/dist/state.cjs.map +1 -1
- package/dist/state.d.cts +7 -0
- package/dist/state.d.ts +7 -0
- package/dist/state.js +9 -3
- package/dist/state.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -737,7 +737,8 @@ async function acquireProfileLock(profile, options) {
|
|
|
737
737
|
const lockPath = profileLockPath(profile);
|
|
738
738
|
const turnDirectory = profileTurnLockPath(profile);
|
|
739
739
|
const directory = profilePath(profile);
|
|
740
|
-
|
|
740
|
+
if (options.requireProfile && !await exists(profileConfigPath(profile))) throw new ProfileDeletedError(profile);
|
|
741
|
+
if (!options.requireProfile) await mkdir(directory, { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
741
742
|
await mkdir(dirname(turnDirectory), { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
742
743
|
for (const path of [tinycloudHomePath(), profilesPath(), directory]) {
|
|
743
744
|
await chmod(path, PRIVATE_DIR_MODE).catch((error) => {
|
|
@@ -746,11 +747,15 @@ async function acquireProfileLock(profile, options) {
|
|
|
746
747
|
}
|
|
747
748
|
const { turn, firstWaitedTurn } = await acquireTurn(profile, turnDirectory, deadline);
|
|
748
749
|
try {
|
|
750
|
+
if (options.requireProfile && !await exists(profileConfigPath(profile))) {
|
|
751
|
+
await rmdir(directory).catch(() => void 0);
|
|
752
|
+
throw new ProfileDeletedError(profile);
|
|
753
|
+
}
|
|
749
754
|
const deletion = await readJson(join(turnDirectory, "deleted.json")).catch(() => null);
|
|
750
755
|
const deletedWhileWaiting = typeof deletion?.slot === "number" && deletion.slot >= firstWaitedTurn;
|
|
751
756
|
while (true) {
|
|
752
757
|
const token = randomUUID();
|
|
753
|
-
if (await publishProfileLock(profile, lockPath, token)) {
|
|
758
|
+
if (await publishProfileLock(profile, lockPath, token, options.requireProfile === true)) {
|
|
754
759
|
return {
|
|
755
760
|
deletedWhileWaiting,
|
|
756
761
|
turnSlot: turn.slot,
|
|
@@ -995,12 +1000,13 @@ async function collectTurns(profile, turn) {
|
|
|
995
1000
|
}
|
|
996
1001
|
}
|
|
997
1002
|
}
|
|
998
|
-
async function publishProfileLock(profile, lockPath, token) {
|
|
1003
|
+
async function publishProfileLock(profile, lockPath, token, requireProfile) {
|
|
999
1004
|
try {
|
|
1000
1005
|
await mkdir(lockPath, { mode: PRIVATE_DIR_MODE });
|
|
1001
1006
|
} catch (error) {
|
|
1002
1007
|
if (isErrno(error, "EEXIST")) return false;
|
|
1003
1008
|
if (!isErrno(error, "ENOENT")) throw error;
|
|
1009
|
+
if (requireProfile) throw new ProfileDeletedError(profile);
|
|
1004
1010
|
await mkdir(profilePath(profile), { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
1005
1011
|
return false;
|
|
1006
1012
|
}
|