From 041ec48b0b3f03cd8e2887d65bb73f8ffb7f72d7 Mon Sep 17 00:00:00 2001 From: Joao Mario Lago Date: Tue, 5 Aug 2025 13:20:33 -0300 Subject: [PATCH 1/2] core:frontend:CloudTrayMenu: Allow dev tokens * Do not remove a file token if it is invalid to allow other services that may use dev tokens to keep working * make sure token is always available at bag and file system so backend service can decide where to fetch and clean from bag if it supports new file system token approach --- .../src/components/cloud/CloudTrayMenu.vue | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/core/frontend/src/components/cloud/CloudTrayMenu.vue b/core/frontend/src/components/cloud/CloudTrayMenu.vue index dc99f483fd..21d94ea1a5 100644 --- a/core/frontend/src/components/cloud/CloudTrayMenu.vue +++ b/core/frontend/src/components/cloud/CloudTrayMenu.vue @@ -286,12 +286,14 @@ export default Vue.extend({ this.operation_error_title = title this.operation_error_message = String(error) }, - async cleanMajorTomToken(): Promise { + async cleanMajorTomBagToken(): Promise { const data = await bag.getData('major_tom') if (data && data.token) { delete data.token } await bag.setData('major_tom', { ...data }) + }, + async cleanMajorTomFileToken(): Promise { await filebrowser.deleteFile(MAJOR_TOM_CLOUD_TOKEN_FILE) }, async fetchMajorTomData(): Promise { @@ -319,18 +321,35 @@ export default Vue.extend({ } if (!await this.isMajorTomTokenValid(tokenToUse, true)) { - await this.cleanMajorTomToken() + /** We do not remove the token since it may be used in other parts as a developer token */ tokenToUse = undefined } else if (tokenToUse !== undefined && tokenToUse !== fileToken) { + /** Copy bag token to file token, migrating to new token system */ await this.updateMajorTomToken(tokenToUse) } this.local_token = tokenToUse ?? '' }, - async updateMajorTomToken(token: string): Promise { + async updateMajorTomBagToken(token: string): Promise { + await this.cleanMajorTomBagToken() + + const tomData = await bag.getData('major_tom') + await bag.setData('major_tom', { ...tomData, token }) + }, + async updateMajorTomFileToken(token: string): Promise { + try { + await this.cleanMajorTomFileToken() + } catch { + /** When updating the token, the file may not exist so we can ignore the error */ + } + await filebrowser.createFile(MAJOR_TOM_CLOUD_TOKEN_FILE.path, true) await filebrowser.writeToFile(MAJOR_TOM_CLOUD_TOKEN_FILE.path, token) }, + async updateMajorTomToken(token: string): Promise { + await this.updateMajorTomBagToken(token) + await this.updateMajorTomFileToken(token) + }, async fetchExtensions(): Promise { if (this.operation_in_progress) { return From 4b0d5135acff19fc9093b7ca5ffd0543eaff2306 Mon Sep 17 00:00:00 2001 From: Joao Mario Lago Date: Thu, 28 Aug 2025 11:25:05 -0300 Subject: [PATCH 2/2] core:frontend:filebrowser: Fix await in async ops * Fix CRUD operations declared as asynced but not awaited correctly creating sync issues in other codes that uses these operations --- core/frontend/src/libs/filebrowser.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/frontend/src/libs/filebrowser.ts b/core/frontend/src/libs/filebrowser.ts index 23fdd45808..c5ed140bef 100644 --- a/core/frontend/src/libs/filebrowser.ts +++ b/core/frontend/src/libs/filebrowser.ts @@ -74,7 +74,7 @@ class Filebrowser { } async createFile(folder_path: string, override: Boolean = false): Promise { - back_axios({ + await back_axios({ method: 'post', url: `${filebrowser_url}/resources${folder_path}?override=${override}`, timeout: 10000, @@ -88,7 +88,7 @@ class Filebrowser { } async writeToFile(file: string, content: string): Promise { - back_axios({ + await back_axios({ method: 'put', url: `/file-browser/api/resources${file}`, timeout: 10000, @@ -108,7 +108,7 @@ class Filebrowser { * @param file - FilebrowserFile object to be deleted * */ async deleteFile(file: FilebrowserFile): Promise { - back_axios({ + await back_axios({ method: 'delete', url: `/file-browser/api/resources${file.path}`, timeout: 10000,