Skip to content
Snippets Groups Projects
Commit ca51ced0 authored by Yogmatee Roochun's avatar Yogmatee Roochun
Browse files

ongoing work

parent d73e8518
No related branches found
No related tags found
2 merge requests!93Shared data model,!94Dev
......@@ -12,3 +12,21 @@ module.exports.createFiles = async function createFiles(filesArr) {
logger.info(filedb)
}
}
module.exports.upsertHtmlPrevFile = async function upsertHtmlPrevFile(
newFile,
manuscriptId,
) {
const existingFiles = await FileModel.selectByManuscriptId(manuscriptId)
const existingFile = existingFiles.find(file => file.type === 'source')
if (existingFile) {
const filedb = await FileModel.updateFileUrl(existingFile.id, newFile.url)
logger.info(filedb)
} else {
const filedb = await new FileModel(newFile).save({
insertMissing: true,
})
logger.info(filedb)
}
}
......@@ -53,7 +53,7 @@ function xsweetConvert(fileUrl, manuscriptId) {
fileInfo.mimeType,
)
delete fileInfo.extension
await db.createFiles([fileInfo])
await db.upsertHtmlPrevFile(fileInfo)
console.log('file has been uploaded to Minio and to db')
} catch (err) {
throw err
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment