From b52f413aa573b410d603f555ac893eeb78fe5545 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 18 Oct 2022 17:04:18 +0100 Subject: [PATCH] Removing attachment dir constant - no longer needed. --- .../src/api/controllers/deploy/index.ts | 21 ++++++++++++------- packages/server/src/constants/index.js | 2 -- packages/server/src/sdk/app/backups/backup.ts | 1 + .../server/src/sdk/app/backups/constants.ts | 2 -- .../server/src/sdk/app/backups/imports.ts | 8 ++----- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/server/src/api/controllers/deploy/index.ts b/packages/server/src/api/controllers/deploy/index.ts index a51e7ad6ec..a1cb905930 100644 --- a/packages/server/src/api/controllers/deploy/index.ts +++ b/packages/server/src/api/controllers/deploy/index.ts @@ -1,23 +1,25 @@ import Deployment from "./Deployment" import { - Replication, - getProdAppID, getDevelopmentAppID, + getProdAppID, + Replication, } from "@budibase/backend-core/db" import { DocumentType, getAutomationParams } from "../../../db/utils" import { + clearMetadata, disableAllCrons, enableCronTrigger, - clearMetadata, } from "../../../automations/utils" import { app as appCache } from "@budibase/backend-core/cache" import { - getAppId, getAppDB, - getProdAppDB, + getAppId, getDevAppDB, + getProdAppDB, } from "@budibase/backend-core/context" import { events } from "@budibase/backend-core" +import { backups } from "@budibase/pro" +import { AppBackupTrigger } from "@budibase/types" // the max time we can wait for an invalidation to complete before considering it failed const MAX_PENDING_TIME_MS = 30 * 60000 @@ -98,13 +100,18 @@ async function initDeployedApp(prodAppId: any) { console.log("Enabled cron triggers for deployed app..") } -async function deployApp(deployment: any) { +async function deployApp(deployment: any, userId: string) { let replication try { const appId = getAppId() const devAppId = getDevelopmentAppID(appId) const productionAppId = getProdAppID(appId) + // trigger backup initially + await backups.triggerAppBackup(productionAppId, AppBackupTrigger.PUBLISH, { + createdBy: userId, + }) + const config: any = { source: devAppId, target: productionAppId, @@ -205,7 +212,7 @@ const _deployApp = async function (ctx: any) { console.log("Deploying app...") - let app = await deployApp(deployment) + let app = await deployApp(deployment, ctx.user._id) await events.app.published(app) ctx.body = deployment diff --git a/packages/server/src/constants/index.js b/packages/server/src/constants/index.js index 6b5bc4bf83..a3bccae754 100644 --- a/packages/server/src/constants/index.js +++ b/packages/server/src/constants/index.js @@ -209,6 +209,4 @@ exports.AutomationErrors = { // pass through the list from the auth/core lib exports.ObjectStoreBuckets = objectStore.ObjectStoreBuckets -exports.ATTACHMENT_DIR = "attachments" - exports.MAX_AUTOMATION_RECURRING_ERRORS = 5 diff --git a/packages/server/src/sdk/app/backups/backup.ts b/packages/server/src/sdk/app/backups/backup.ts index 2a85424f71..92f70a5a84 100644 --- a/packages/server/src/sdk/app/backups/backup.ts +++ b/packages/server/src/sdk/app/backups/backup.ts @@ -11,6 +11,7 @@ async function importProcessor(job: Job) { const appId = data.appId, backupId = data.import!.backupId const { path, metadata } = await backups.downloadAppBackup(backupId) + // start by removing app database and contents of bucket - which will be updated } async function exportProcessor(job: Job) { diff --git a/packages/server/src/sdk/app/backups/constants.ts b/packages/server/src/sdk/app/backups/constants.ts index f022168846..2f011ea2de 100644 --- a/packages/server/src/sdk/app/backups/constants.ts +++ b/packages/server/src/sdk/app/backups/constants.ts @@ -1,4 +1,2 @@ -import { ATTACHMENT_DIR as attachmentDir } from "../../../constants" export const DB_EXPORT_FILE = "db.txt" -export const ATTACHMENT_DIR = attachmentDir export const GLOBAL_DB_EXPORT_FILE = "global.txt" diff --git a/packages/server/src/sdk/app/backups/imports.ts b/packages/server/src/sdk/app/backups/imports.ts index b63a0ee922..b29a9eede5 100644 --- a/packages/server/src/sdk/app/backups/imports.ts +++ b/packages/server/src/sdk/app/backups/imports.ts @@ -1,17 +1,13 @@ import { db as dbCore } from "@budibase/backend-core" import { TABLE_ROW_PREFIX } from "../../../db/utils" import { budibaseTempDir } from "../../../utilities/budibaseDir" -import { - DB_EXPORT_FILE, - ATTACHMENT_DIR, - GLOBAL_DB_EXPORT_FILE, -} from "./constants" +import { DB_EXPORT_FILE, GLOBAL_DB_EXPORT_FILE } from "./constants" import { uploadDirectory, upload, } from "../../../utilities/fileSystem/utilities" import { ObjectStoreBuckets, FieldTypes } from "../../../constants" -import { join, basename } from "path" +import { join } from "path" import fs from "fs" import sdk from "../../" import { CouchFindOptions, RowAttachment } from "@budibase/types"