1
0
Fork 0
mirror of synced 2024-06-14 08:24:48 +12:00

Fixing an issue with some browsers sending the gzip type as x-gzip rather than gzip, which caused the processing to fail.

This commit is contained in:
mike12345567 2022-10-27 19:14:31 +01:00
parent 3873f0a27f
commit 1c012ee7f7

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)) {