Skip to content

Commit ea29f10

Browse files
committed
Remove uploaded Project archives after import
1 parent 306c19a commit ea29f10

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

‎packages/server/src/api/controllers/project.ts‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
UpdateProjectRequest,
1414
UpdateProjectResponse,
1515
} from "@budibase/types"
16+
import fsp from "fs/promises"
1617
import sdk from "../../sdk"
1718

1819
export const toProjectResponse = (project: Project): ProjectResponse => {
@@ -123,12 +124,18 @@ export async function importBundle(
123124
ctx.throw(400, "Must supply Project export file to import")
124125
}
125126

126-
ctx.body = await sdk.projects.importProject(
127-
{
128-
path: filePath,
129-
},
130-
{
131-
encryptPassword: ctx.request.body?.encryptPassword || undefined,
132-
}
133-
)
127+
try {
128+
ctx.body = await sdk.projects.importProject(
129+
{
130+
path: filePath,
131+
},
132+
{
133+
encryptPassword: ctx.request.body?.encryptPassword || undefined,
134+
}
135+
)
136+
} finally {
137+
await fsp.rm(filePath, { force: true }).catch(error => {
138+
console.log("Failed to remove uploaded Project import archive", error)
139+
})
140+
}
134141
}

0 commit comments

Comments
 (0)