mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
qdb data file overwrite fix
This commit is contained in:
@@ -273,13 +273,22 @@ function writeNewData(
|
||||
publicDir: string
|
||||
) {
|
||||
const qdbsToWrite = [...changedQuestionDbs, ...newQuestionDbs]
|
||||
const qdbsFile: DataFile[] = qdbsToWrite.map((qdb) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { data, index, ...restOfQdb } = qdb
|
||||
return restOfQdb
|
||||
})
|
||||
const existingQdbs = utils.ReadJSON<DataFile[]>(dbsFilePath)
|
||||
|
||||
utils.WriteFile(JSON.stringify(qdbsFile, null, 2), dbsFilePath)
|
||||
const qdbDataToWrite = qdbsToWrite.reduce((acc, qdb) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { data, index, ...qdbData } = qdb
|
||||
const existingQdbData = acc.find((data) => {
|
||||
return data.name === qdbData.name
|
||||
})
|
||||
if (!existingQdbData) {
|
||||
return [...acc, qdbData]
|
||||
} else {
|
||||
return acc
|
||||
}
|
||||
}, existingQdbs)
|
||||
|
||||
utils.WriteFile(JSON.stringify(qdbDataToWrite, null, 2), dbsFilePath)
|
||||
qdbsToWrite.forEach((qdb) => {
|
||||
try {
|
||||
writeData(qdb.data, publicDir + qdb.path)
|
||||
|
Submodule submodules/qmining-page updated: 338db8e141...62fb75ec5f
Reference in New Issue
Block a user