Changing how disk cleanup is performed.
This commit is contained in:
parent
ac53a97176
commit
2c86ea14fd
2 changed files with 10 additions and 15 deletions
|
@ -352,20 +352,15 @@ export class DatabaseImpl implements Database {
|
||||||
}
|
}
|
||||||
|
|
||||||
async destroy() {
|
async destroy() {
|
||||||
|
if (env.SQS_SEARCH_ENABLE && (await this.exists(SQLITE_DESIGN_DOC_ID))) {
|
||||||
|
// delete the design document, then run the cleanup operation
|
||||||
|
const definition = await this.get<SQLiteDefinition>(SQLITE_DESIGN_DOC_ID)
|
||||||
|
// remove all tables - save the definition then trigger a cleanup
|
||||||
|
definition.sql.tables = {}
|
||||||
|
await this.put(definition)
|
||||||
|
await this.sqlDiskCleanup()
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if (env.SQS_SEARCH_ENABLE) {
|
|
||||||
// delete the design document, then run the cleanup operation
|
|
||||||
try {
|
|
||||||
const definition = await this.get<SQLiteDefinition>(
|
|
||||||
SQLITE_DESIGN_DOC_ID
|
|
||||||
)
|
|
||||||
await this.remove(SQLITE_DESIGN_DOC_ID, definition._rev)
|
|
||||||
} catch (err: any) {
|
|
||||||
// design document doesn't exist, don't worry
|
|
||||||
} finally {
|
|
||||||
await this.sqlDiskCleanup()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return await this.nano().db.destroy(this.name)
|
return await this.nano().db.destroy(this.name)
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
// didn't exist, don't worry
|
// didn't exist, don't worry
|
||||||
|
|
|
@ -331,11 +331,11 @@ describe("/applications", () => {
|
||||||
|
|
||||||
it("should delete published app and dev app with prod app ID", async () => {
|
it("should delete published app and dev app with prod app ID", async () => {
|
||||||
await config.api.application.delete(app.appId.replace("_dev", ""))
|
await config.api.application.delete(app.appId.replace("_dev", ""))
|
||||||
expect(events.app.deleted).toHaveBeenCalledTmes(1)
|
expect(events.app.deleted).toHaveBeenCalledTimes(1)
|
||||||
expect(events.app.unpublished).toHaveBeenCalledTimes(1)
|
expect(events.app.unpublished).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
it.only("should be able to delete an app after SQS_SEARCH_ENABLE has been set but app hasn't been migrated", async () => {
|
it("should be able to delete an app after SQS_SEARCH_ENABLE has been set but app hasn't been migrated", async () => {
|
||||||
await config.withCoreEnv({ SQS_SEARCH_ENABLE: "true" }, async () => {
|
await config.withCoreEnv({ SQS_SEARCH_ENABLE: "true" }, async () => {
|
||||||
await config.api.application.delete(app.appId)
|
await config.api.application.delete(app.appId)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue