From 407d7606e9271bc07023d74871bc1418a60cae1e Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 13 Oct 2020 16:31:14 +0100 Subject: [PATCH 1/6] Destroying instance DBs for an app before it is deleted. --- packages/server/src/api/controllers/application.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/server/src/api/controllers/application.js b/packages/server/src/api/controllers/application.js index 53b8792f49..28e389b1d2 100644 --- a/packages/server/src/api/controllers/application.js +++ b/packages/server/src/api/controllers/application.js @@ -116,6 +116,12 @@ exports.delete = async function(ctx) { const db = new CouchDB(ClientDb.name(getClientId(ctx))) const app = await db.get(ctx.params.applicationId) const result = await db.remove(app) + for (let instance of app.instances) { + const instanceDb = new CouchDB(instance._id) + await instanceDb.destroy() + } + + // remove top level directory await fs.rmdir(join(budibaseAppsDir(), ctx.params.applicationId), { recursive: true, }) From 3fd5e7e57894fd5a155d1104bf853b813e5e679d Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 13 Oct 2020 17:02:59 +0100 Subject: [PATCH 2/6] Removing deprecated function - exists. --- packages/server/src/api/controllers/application.js | 4 ++-- packages/server/src/utilities/initialiseBudibase.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/server/src/api/controllers/application.js b/packages/server/src/api/controllers/application.js index 28e389b1d2..0d8fe021be 100644 --- a/packages/server/src/api/controllers/application.js +++ b/packages/server/src/api/controllers/application.js @@ -3,7 +3,7 @@ const ClientDb = require("../../db/clientDb") const { getPackageForBuilder, buildPage } = require("../../utilities/builder") const env = require("../../environment") const instanceController = require("./instance") -const { copy, exists, readFile, writeFile } = require("fs-extra") +const { copy, existsSync, readFile, writeFile } = require("fs-extra") const { budibaseAppsDir } = require("../../utilities/budibaseDir") const sqrl = require("squirrelly") const setBuilderToken = require("../../utilities/builder/setBuilderToken") @@ -143,7 +143,7 @@ const createEmptyAppPackage = async (ctx, app) => { const appsFolder = budibaseAppsDir() const newAppFolder = resolve(appsFolder, app._id) - if (await exists(newAppFolder)) { + if (existsSync(newAppFolder)) { ctx.throw(400, "App folder already exists for this application") } diff --git a/packages/server/src/utilities/initialiseBudibase.js b/packages/server/src/utilities/initialiseBudibase.js index c86b6083e9..be3253117c 100644 --- a/packages/server/src/utilities/initialiseBudibase.js +++ b/packages/server/src/utilities/initialiseBudibase.js @@ -1,4 +1,4 @@ -const { exists, readFile, writeFile, ensureDir } = require("fs-extra") +const { existsSync, readFile, writeFile, ensureDir } = require("fs-extra") const { join, resolve } = require("./centralPath") const Sqrl = require("squirrelly") const uuid = require("uuid") @@ -28,7 +28,7 @@ const setCouchDbUrl = async opts => { const createDevEnvFile = async opts => { const destConfigFile = join(opts.dir, "./.env") - let createConfig = !(await exists(destConfigFile)) || opts.quiet + let createConfig = !existsSync(destConfigFile) || opts.quiet if (createConfig) { const template = await readFile( resolve(__dirname, "..", "..", ".env.template"), From 686d85f07e6c7b1511c38eee0e5e915f6b42b03b Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 13 Oct 2020 17:40:28 +0100 Subject: [PATCH 3/6] Adding 501 not implemented errors to screen API which did not have a controller previously. --- packages/server/src/api/controllers/page.js | 0 packages/server/src/api/controllers/screen.js | 17 +++++++++++++++++ 2 files changed, 17 insertions(+) delete mode 100644 packages/server/src/api/controllers/page.js diff --git a/packages/server/src/api/controllers/page.js b/packages/server/src/api/controllers/page.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/server/src/api/controllers/screen.js b/packages/server/src/api/controllers/screen.js index e69de29bb2..91c3c83dd5 100644 --- a/packages/server/src/api/controllers/screen.js +++ b/packages/server/src/api/controllers/screen.js @@ -0,0 +1,17 @@ +/** + * This controller is not currently fully implemented. Screens are + * currently managed as part of the pages API, please look in api/routes/page.js + * for routes and controllers. + */ + +exports.fetch = async ctx => { + ctx.throw(501) +} + +exports.save = async ctx => { + ctx.throw(501) +} + +exports.destroy = async ctx => { + ctx.throw(501) +} From 7e70eb0f2051f26d971ca26efb228429cb011bab Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 13 Oct 2020 19:37:52 +0100 Subject: [PATCH 4/6] Adding info to the table deletion about screens that will be deleted and deleted template screens when table deleted. --- .../popovers/EditTablePopover.svelte | 49 +++++++++++++++++-- .../components/common/ConfirmDialog.svelte | 2 +- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/packages/builder/src/components/backend/TableNavigator/popovers/EditTablePopover.svelte b/packages/builder/src/components/backend/TableNavigator/popovers/EditTablePopover.svelte index 9df5f36993..d9e7e6867b 100644 --- a/packages/builder/src/components/backend/TableNavigator/popovers/EditTablePopover.svelte +++ b/packages/builder/src/components/backend/TableNavigator/popovers/EditTablePopover.svelte @@ -1,9 +1,11 @@