1
0
Fork 0
mirror of synced 2024-06-14 00:14:39 +12:00

Adding a fix for checklist being incorrect after restoring from the CLI.

This commit is contained in:
mike12345567 2022-10-27 09:48:37 +01:00
parent 406cd53d11
commit 2900ef2fde
6 changed files with 45 additions and 1 deletions

View file

@ -4,7 +4,7 @@ const fs = require("fs")
const { join } = require("path")
const { getAllDbs } = require("../core/db")
const tar = require("tar")
const { progressBar } = require("../utils")
const { progressBar, httpCall } = require("../utils")
const {
TEMP_DIR,
COUCH_DIR,
@ -86,6 +86,15 @@ async function importBackup(opts) {
bar.stop()
console.log("MinIO Import")
await importObjects()
// finish by letting the system know that a restore has occurred
try {
await httpCall(
`http://localhost:${config.MAIN_PORT}/api/system/restored`,
"POST"
)
} catch (err) {
// ignore error - it will be an older system
}
console.log("Import complete")
fs.rmSync(TEMP_DIR, { recursive: true })
}

View file

@ -23,6 +23,14 @@ exports.downloadFile = async (url, filePath) => {
})
}
exports.httpCall = async (url, method) => {
const response = await axios({
url,
method,
})
return response.data
}
exports.getHelpDescription = string => {
return chalk.cyan(string)
}

View file

@ -0,0 +1,13 @@
import env from "../../../environment"
import { BBContext } from "@budibase/types"
import { cache } from "@budibase/backend-core"
export async function systemRestored(ctx: BBContext) {
if (!env.SELF_HOSTED) {
ctx.throw(405, "This operation is not allowed in cloud.")
}
await cache.bustCache(cache.CacheKeys.CHECKLIST)
ctx.body = {
message: "System prepared after restore.",
}
}

View file

@ -55,6 +55,10 @@ const PUBLIC_ENDPOINTS = [
route: "/api/global/users/tenant/:id",
method: "GET",
},
{
route: "/api/system/restored",
method: "POST",
},
]
const NO_TENANCY_ENDPOINTS = [

View file

@ -13,6 +13,7 @@ import selfRoutes from "./global/self"
import licenseRoutes from "./global/license"
import migrationRoutes from "./system/migrations"
import accountRoutes from "./system/accounts"
import restoreRoutes from "./system/restore"
let userGroupRoutes = api.groups
export const routes = [
@ -31,4 +32,5 @@ export const routes = [
userGroupRoutes,
migrationRoutes,
accountRoutes,
restoreRoutes,
]

View file

@ -0,0 +1,8 @@
import * as controller from "../../controllers/system/restore"
import Router from "@koa/router"
const router = new Router()
router.post("/api/system/restored", controller.systemRestored)
export = router