Breaking attachment out into constant that can be re-used, and fixing some imports.
This commit is contained in:
parent
2f6bcdd620
commit
0727df6f98
|
@ -1,3 +1,4 @@
|
|||
export const DB_EXPORT_FILE = "db.txt"
|
||||
export const GLOBAL_DB_EXPORT_FILE = "global.txt"
|
||||
export const STATIC_APP_FILES = ["manifest.json", "budibase-client.js"]
|
||||
export const ATTACHMENT_DIRECTORY = "attachments"
|
||||
|
|
|
@ -8,13 +8,15 @@ import {
|
|||
TABLE_ROW_PREFIX,
|
||||
USER_METDATA_PREFIX,
|
||||
} from "../../../db/utils"
|
||||
import { DB_EXPORT_FILE, STATIC_APP_FILES } from "./constants"
|
||||
import {
|
||||
DB_EXPORT_FILE,
|
||||
STATIC_APP_FILES,
|
||||
ATTACHMENT_DIRECTORY,
|
||||
} from "./constants"
|
||||
import fs from "fs"
|
||||
import { join } from "path"
|
||||
import env from "../../../environment"
|
||||
|
||||
const uuid = require("uuid/v4")
|
||||
|
||||
import { v4 as uuid } from "uuid"
|
||||
import tar from "tar"
|
||||
|
||||
const MemoryStream = require("memorystream")
|
||||
|
@ -150,7 +152,7 @@ export async function exportApp(appId: string, config?: ExportOpts) {
|
|||
const path = join(tmpPath, file)
|
||||
|
||||
// skip the attachments - too big to encrypt
|
||||
if (file !== "attachments") {
|
||||
if (file !== ATTACHMENT_DIRECTORY) {
|
||||
await encryption.encryptFile(
|
||||
{ dir: tmpPath, filename: file },
|
||||
config.encryptPassword
|
||||
|
|
|
@ -8,15 +8,18 @@ import {
|
|||
} from "@budibase/types"
|
||||
import { getAutomationParams } from "../../../db/utils"
|
||||
import { budibaseTempDir } from "../../../utilities/budibaseDir"
|
||||
import { DB_EXPORT_FILE, GLOBAL_DB_EXPORT_FILE } from "./constants"
|
||||
import {
|
||||
DB_EXPORT_FILE,
|
||||
GLOBAL_DB_EXPORT_FILE,
|
||||
ATTACHMENT_DIRECTORY,
|
||||
} from "./constants"
|
||||
import { downloadTemplate } from "../../../utilities/fileSystem"
|
||||
import { ObjectStoreBuckets } from "../../../constants"
|
||||
import { join } from "path"
|
||||
import fs from "fs"
|
||||
import sdk from "../../"
|
||||
|
||||
const uuid = require("uuid/v4")
|
||||
const tar = require("tar")
|
||||
import { v4 as uuid } from "uuid"
|
||||
import tar from "tar"
|
||||
|
||||
type TemplateType = {
|
||||
file?: {
|
||||
|
@ -129,7 +132,7 @@ async function decryptFiles(path: string, password: string) {
|
|||
try {
|
||||
for (let file of fs.readdirSync(path)) {
|
||||
const inputPath = join(path, file)
|
||||
if (!inputPath.endsWith("attachments")) {
|
||||
if (!inputPath.endsWith(ATTACHMENT_DIRECTORY)) {
|
||||
const outputPath = inputPath.replace(/\.enc$/, "")
|
||||
await encryption.decryptFile(inputPath, outputPath, password)
|
||||
fs.rmSync(inputPath)
|
||||
|
|
Loading…
Reference in New Issue