From 010f160fa54089eef6a8d75ae289bdd93ee5151e Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 31 Jan 2024 18:22:18 +0000 Subject: [PATCH] Cleaning up files after import is finished (with large files this saves on tmp space) as well as fixing an issue where menu would appear next to a restore despite having no options. --- .../backups/_components/ActionsRenderer.svelte | 16 ++++++++-------- packages/pro | 2 +- packages/server/src/sdk/app/backups/imports.ts | 7 ++++++- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/packages/builder/src/pages/builder/app/[application]/settings/backups/_components/ActionsRenderer.svelte b/packages/builder/src/pages/builder/app/[application]/settings/backups/_components/ActionsRenderer.svelte index 93f0f518ad..ffdf14fdce 100644 --- a/packages/builder/src/pages/builder/app/[application]/settings/backups/_components/ActionsRenderer.svelte +++ b/packages/builder/src/pages/builder/app/[application]/settings/backups/_components/ActionsRenderer.svelte @@ -13,6 +13,7 @@ import CreateRestoreModal from "./CreateRestoreModal.svelte" import { createEventDispatcher } from "svelte" import { isOnlyUser } from "builderStore" + import { BackupType } from "constants/backend/backups" export let row @@ -42,12 +43,11 @@
- -
- -
- - {#if row.type !== "restore"} + {#if row.type !== BackupType.RESTORE} + +
+ +
Delete Download - {/if} -
+
+ {/if}
diff --git a/packages/pro b/packages/pro index e4dab7e4cc..f8ebf7e3e1 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit e4dab7e4ccb4a1e2864a35dd2a851ca1a898e6c6 +Subproject commit f8ebf7e3e14c894cf7ab831fabd2706e94cfb830 diff --git a/packages/server/src/sdk/app/backups/imports.ts b/packages/server/src/sdk/app/backups/imports.ts index 7f76945107..4c5c1e659d 100644 --- a/packages/server/src/sdk/app/backups/imports.ts +++ b/packages/server/src/sdk/app/backups/imports.ts @@ -165,8 +165,9 @@ export async function importApp( const isTar = template.file && template?.file?.type?.endsWith("gzip") const isDirectory = template.file && fs.lstatSync(template.file.path).isDirectory() + let tmpPath: string | undefined = undefined if (template.file && (isTar || isDirectory)) { - const tmpPath = isTar ? await untarFile(template.file) : template.file.path + tmpPath = isTar ? await untarFile(template.file) : template.file.path if (isTar && template.file.password) { await decryptFiles(tmpPath, template.file.password) } @@ -208,5 +209,9 @@ export async function importApp( } await updateAttachmentColumns(prodAppId, db) await updateAutomations(prodAppId, db) + // clear up afterward + if (tmpPath) { + fs.rmSync(tmpPath, { recursive: true, force: true }) + } return ok }