mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-28 20:31:16 +00:00
fix: app creation dupped names limit (#3130)
* fix: app creation dupped names limit * fix: app dupped names
This commit is contained in:
Generated
+1
-1
@@ -19199,7 +19199,7 @@
|
||||
},
|
||||
"src/puter-js": {
|
||||
"name": "@heyputer/puter.js",
|
||||
"version": "2.3.2",
|
||||
"version": "2.3.4",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@heyputer/kv.js": "^0.2.1",
|
||||
|
||||
@@ -157,13 +157,16 @@ export class AppDriver extends PuterDriver {
|
||||
if (await this.appStore.existsByName(fields.name)) {
|
||||
if (options?.dedupe_name) {
|
||||
let candidate;
|
||||
let n = 1;
|
||||
let i = 0;
|
||||
do {
|
||||
candidate = `${fields.name}-${++n}`;
|
||||
if (n > 50)
|
||||
const randString = Math.random().toString(36).slice(2, 6);
|
||||
candidate = `${fields.name}-${randString}`;
|
||||
|
||||
if (i >= 3)
|
||||
throw new HttpError(400, 'Failed to dedupe app name', {
|
||||
legacyCode: 'bad_request',
|
||||
legacyCode: 'app_name_already_in_use',
|
||||
});
|
||||
i++;
|
||||
} while (await this.appStore.existsByName(candidate));
|
||||
fields.name = candidate;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user