@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/cli-runtime.cjs
CHANGED
|
@@ -721,7 +721,8 @@ async function acquireProfileLock(profile, options) {
|
|
|
721
721
|
const lockPath = profileLockPath(profile);
|
|
722
722
|
const turnDirectory = profileTurnLockPath(profile);
|
|
723
723
|
const directory = profilePath(profile);
|
|
724
|
-
|
|
724
|
+
if (options.requireProfile && !await exists(profileConfigPath(profile))) throw new ProfileDeletedError(profile);
|
|
725
|
+
if (!options.requireProfile) await (0, import_promises.mkdir)(directory, { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
725
726
|
await (0, import_promises.mkdir)((0, import_node_path.dirname)(turnDirectory), { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
726
727
|
for (const path of [tinycloudHomePath(), profilesPath(), directory]) {
|
|
727
728
|
await (0, import_promises.chmod)(path, PRIVATE_DIR_MODE).catch((error) => {
|
|
@@ -730,11 +731,15 @@ async function acquireProfileLock(profile, options) {
|
|
|
730
731
|
}
|
|
731
732
|
const { turn, firstWaitedTurn } = await acquireTurn(profile, turnDirectory, deadline);
|
|
732
733
|
try {
|
|
734
|
+
if (options.requireProfile && !await exists(profileConfigPath(profile))) {
|
|
735
|
+
await (0, import_promises.rmdir)(directory).catch(() => void 0);
|
|
736
|
+
throw new ProfileDeletedError(profile);
|
|
737
|
+
}
|
|
733
738
|
const deletion = await readJson((0, import_node_path.join)(turnDirectory, "deleted.json")).catch(() => null);
|
|
734
739
|
const deletedWhileWaiting = typeof deletion?.slot === "number" && deletion.slot >= firstWaitedTurn;
|
|
735
740
|
while (true) {
|
|
736
741
|
const token = (0, import_node_crypto.randomUUID)();
|
|
737
|
-
if (await publishProfileLock(profile, lockPath, token)) {
|
|
742
|
+
if (await publishProfileLock(profile, lockPath, token, options.requireProfile === true)) {
|
|
738
743
|
return {
|
|
739
744
|
deletedWhileWaiting,
|
|
740
745
|
turnSlot: turn.slot,
|
|
@@ -979,12 +984,13 @@ async function collectTurns(profile, turn) {
|
|
|
979
984
|
}
|
|
980
985
|
}
|
|
981
986
|
}
|
|
982
|
-
async function publishProfileLock(profile, lockPath, token) {
|
|
987
|
+
async function publishProfileLock(profile, lockPath, token, requireProfile) {
|
|
983
988
|
try {
|
|
984
989
|
await (0, import_promises.mkdir)(lockPath, { mode: PRIVATE_DIR_MODE });
|
|
985
990
|
} catch (error) {
|
|
986
991
|
if (isErrno(error, "EEXIST")) return false;
|
|
987
992
|
if (!isErrno(error, "ENOENT")) throw error;
|
|
993
|
+
if (requireProfile) throw new ProfileDeletedError(profile);
|
|
988
994
|
await (0, import_promises.mkdir)(profilePath(profile), { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
989
995
|
return false;
|
|
990
996
|
}
|