@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
package/dist/artifacts.js
CHANGED
|
@@ -577,7 +577,8 @@ async function acquireProfileLock(profile, options) {
|
|
|
577
577
|
const lockPath = profileLockPath(profile);
|
|
578
578
|
const turnDirectory = profileTurnLockPath(profile);
|
|
579
579
|
const directory = profilePath(profile);
|
|
580
|
-
|
|
580
|
+
if (options.requireProfile && !await exists(profileConfigPath(profile))) throw new ProfileDeletedError(profile);
|
|
581
|
+
if (!options.requireProfile) await mkdir(directory, { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
581
582
|
await mkdir(dirname(turnDirectory), { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
582
583
|
for (const path of [tinycloudHomePath(), profilesPath(), directory]) {
|
|
583
584
|
await chmod(path, PRIVATE_DIR_MODE).catch((error) => {
|
|
@@ -586,11 +587,15 @@ async function acquireProfileLock(profile, options) {
|
|
|
586
587
|
}
|
|
587
588
|
const { turn, firstWaitedTurn } = await acquireTurn(profile, turnDirectory, deadline);
|
|
588
589
|
try {
|
|
590
|
+
if (options.requireProfile && !await exists(profileConfigPath(profile))) {
|
|
591
|
+
await rmdir(directory).catch(() => void 0);
|
|
592
|
+
throw new ProfileDeletedError(profile);
|
|
593
|
+
}
|
|
589
594
|
const deletion = await readJson(join(turnDirectory, "deleted.json")).catch(() => null);
|
|
590
595
|
const deletedWhileWaiting = typeof deletion?.slot === "number" && deletion.slot >= firstWaitedTurn;
|
|
591
596
|
while (true) {
|
|
592
597
|
const token = randomUUID();
|
|
593
|
-
if (await publishProfileLock(profile, lockPath, token)) {
|
|
598
|
+
if (await publishProfileLock(profile, lockPath, token, options.requireProfile === true)) {
|
|
594
599
|
return {
|
|
595
600
|
deletedWhileWaiting,
|
|
596
601
|
turnSlot: turn.slot,
|
|
@@ -841,12 +846,13 @@ async function collectTurns(profile, turn) {
|
|
|
841
846
|
}
|
|
842
847
|
}
|
|
843
848
|
}
|
|
844
|
-
async function publishProfileLock(profile, lockPath, token) {
|
|
849
|
+
async function publishProfileLock(profile, lockPath, token, requireProfile) {
|
|
845
850
|
try {
|
|
846
851
|
await mkdir(lockPath, { mode: PRIVATE_DIR_MODE });
|
|
847
852
|
} catch (error) {
|
|
848
853
|
if (isErrno(error, "EEXIST")) return false;
|
|
849
854
|
if (!isErrno(error, "ENOENT")) throw error;
|
|
855
|
+
if (requireProfile) throw new ProfileDeletedError(profile);
|
|
850
856
|
await mkdir(profilePath(profile), { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
851
857
|
return false;
|
|
852
858
|
}
|