@tinycloud/operations 0.4.0-beta.13 → 0.4.0-beta.15
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
|
@@ -582,7 +582,8 @@ async function acquireProfileLock(profile, options) {
|
|
|
582
582
|
const lockPath = profileLockPath(profile);
|
|
583
583
|
const turnDirectory = profileTurnLockPath(profile);
|
|
584
584
|
const directory = profilePath(profile);
|
|
585
|
-
|
|
585
|
+
if (options.requireProfile && !await exists(profileConfigPath(profile))) throw new ProfileDeletedError(profile);
|
|
586
|
+
if (!options.requireProfile) await mkdir(directory, { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
586
587
|
await mkdir(dirname(turnDirectory), { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
587
588
|
for (const path of [tinycloudHomePath(), profilesPath(), directory]) {
|
|
588
589
|
await chmod(path, PRIVATE_DIR_MODE).catch((error) => {
|
|
@@ -591,11 +592,15 @@ async function acquireProfileLock(profile, options) {
|
|
|
591
592
|
}
|
|
592
593
|
const { turn, firstWaitedTurn } = await acquireTurn(profile, turnDirectory, deadline);
|
|
593
594
|
try {
|
|
595
|
+
if (options.requireProfile && !await exists(profileConfigPath(profile))) {
|
|
596
|
+
await rmdir(directory).catch(() => void 0);
|
|
597
|
+
throw new ProfileDeletedError(profile);
|
|
598
|
+
}
|
|
594
599
|
const deletion = await readJson(join(turnDirectory, "deleted.json")).catch(() => null);
|
|
595
600
|
const deletedWhileWaiting = typeof deletion?.slot === "number" && deletion.slot >= firstWaitedTurn;
|
|
596
601
|
while (true) {
|
|
597
602
|
const token = randomUUID();
|
|
598
|
-
if (await publishProfileLock(profile, lockPath, token)) {
|
|
603
|
+
if (await publishProfileLock(profile, lockPath, token, options.requireProfile === true)) {
|
|
599
604
|
return {
|
|
600
605
|
deletedWhileWaiting,
|
|
601
606
|
turnSlot: turn.slot,
|
|
@@ -846,12 +851,13 @@ async function collectTurns(profile, turn) {
|
|
|
846
851
|
}
|
|
847
852
|
}
|
|
848
853
|
}
|
|
849
|
-
async function publishProfileLock(profile, lockPath, token) {
|
|
854
|
+
async function publishProfileLock(profile, lockPath, token, requireProfile) {
|
|
850
855
|
try {
|
|
851
856
|
await mkdir(lockPath, { mode: PRIVATE_DIR_MODE });
|
|
852
857
|
} catch (error) {
|
|
853
858
|
if (isErrno(error, "EEXIST")) return false;
|
|
854
859
|
if (!isErrno(error, "ENOENT")) throw error;
|
|
860
|
+
if (requireProfile) throw new ProfileDeletedError(profile);
|
|
855
861
|
await mkdir(profilePath(profile), { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
856
862
|
return false;
|
|
857
863
|
}
|