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.

This commit is contained in:
mike12345567 2024-01-31 18:22:18 +00:00
parent 85f7d66a99
commit 010f160fa5
3 changed files with 15 additions and 10 deletions

View File

@ -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 @@
</script>
<div class="cell">
<ActionMenu align="right">
<div slot="control">
<Icon size="M" hoverable name="MoreSmallList" />
</div>
{#if row.type !== "restore"}
{#if row.type !== BackupType.RESTORE}
<ActionMenu align="right">
<div slot="control">
<Icon size="M" hoverable name="MoreSmallList" />
</div>
<AbsTooltip
position={TooltipPosition.Left}
text="Unavailable - another user is editing this app"
@ -62,8 +62,8 @@
</AbsTooltip>
<MenuItem on:click={deleteDialog.show} icon="Delete">Delete</MenuItem>
<MenuItem on:click={downloadExport} icon="Download">Download</MenuItem>
{/if}
</ActionMenu>
</ActionMenu>
{/if}
</div>
<Modal bind:this={restoreBackupModal}>

@ -1 +1 @@
Subproject commit e4dab7e4ccb4a1e2864a35dd2a851ca1a898e6c6
Subproject commit f8ebf7e3e14c894cf7ab831fabd2706e94cfb830

View File

@ -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
}