1
0
Fork 0
mirror of synced 2024-06-26 18:10:51 +12:00

Merge pull request #8429 from Budibase/fix/gzip-import

Fixing server to handle both gzip and x-gzip mimetypes for app imports
This commit is contained in:
Michael Drury 2022-10-27 20:13:01 +01:00 committed by GitHub
commit 1af6cf1326
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -120,6 +120,9 @@ async function updateAutomations(prodAppId: string, db: PouchDB.Database) {
* @returns {Object} Returns a fs read stream which can be loaded into the database.
*/
async function getTemplateStream(template: TemplateType) {
if (template.file && template.file.type !== "text/plain") {
throw new Error("Cannot import a non-text based file.")
}
if (template.file) {
return fs.createReadStream(template.file.path)
} else if (template.key) {
@ -156,7 +159,7 @@ export async function importApp(
) {
let prodAppId = dbCore.getProdAppID(appId)
let dbStream: any
const isTar = template.file && template.file.type === "application/gzip"
const isTar = template.file && template?.file?.type?.endsWith("gzip")
const isDirectory =
template.file && fs.lstatSync(template.file.path).isDirectory()
if (template.file && (isTar || isDirectory)) {