Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove lokue db If json damaged #365

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions workers/api.framework.report.wrk.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict'

const fs = require('node:fs')

const WrkReportServiceApi = require(
'bfx-report/workers/api.service.report.wrk'
)
Expand Down Expand Up @@ -143,6 +145,31 @@ class WrkReportFrameWorkApi extends WrkReportServiceApi {
}

this.setInitFacs(facs)
this.rmLokueDbIfJSONDamaged()
}

rmLokueDbIfJSONDamaged () {
for (const fac of this.conf.init.facilities) {
// eslint-disable-next-line no-unused-vars
const [type, facName, ns, label, opts] = fac

if (facName !== 'bfx-facs-lokue') {
continue
}

const { dbPathAbsolute, name } = opts
const baseLokueDbFileName = ['lokue', name, label].join('_')
const pathToLokueDbFile = path.join(
dbPathAbsolute,
`${baseLokueDbFileName}.db.json`
)

try {
require(pathToLokueDbFile)
} catch (err) {
fs.rmSync(pathToLokueDbFile, { force: true, maxRetries: 3 })
}
}
}

async initService (deps) {
Expand Down