Commit d3794c1f authored by Audrey Hamelers's avatar Audrey Hamelers
parent ae43bc5c
Pipeline #13087 passed with stages
in 5 minutes and 40 seconds
......@@ -353,31 +353,51 @@ function retryNcbiApiCall(
}
async function deposit(manuscript, adminUser) {
if (manuscript.files) {
const nxml =
manuscript.files &&
manuscript.files.find(file => !file.deleted && file.type === 'PMCfinal')
const files =
manuscript.files &&
manuscript.files.filter(file => !file.deleted && file.type === 'IMGprint')
const bigfiles = files.filter(file => file.size > 20000000)
if (bigfiles.length > 0) {
const err = `Unable to generate PDF. The following TIFF files are too large:\n${bigfiles
.map(f => f.filename)
.join('\n')}`
logger.error(err)
await manuscriptModel.update(
{
id: manuscript.id,
formState: err,
pdfDepositState: null,
status:
manuscript.status === 'tagging' ? 'xml-triage' : manuscript.status,
},
adminUser.id,
)
} else if (nxml) {
logger.info(`Start depositing ${manuscript.id}`)
files.push(nxml)
const depositObj = {
action: 'commit',
depositor: 'ebi',
domain: 'ukpmcpa',
items: [],
}
manuscript.files
.filter(
file =>
!file.deleted &&
(file.type === 'PMCfinal' || file.type === 'IMGprint'),
)
.forEach(file => {
depositObj.items.push({
item: `${baseUrl}${file.url}`,
item_size: file.size,
})
})
depositObj.items = files.map(file => ({
item: `${baseUrl}${file.url}`,
item_size: file.size,
}))
// retry method(adminUser, attempt_number, manuscriptObj, depositObj)
await retryNcbiApiCall(adminUser, 1, manuscript, depositObj)
} else {
logger.info(`No files to deposit for manuscript ${manuscript.id}`)
logger.error(`No files to deposit for manuscript ${manuscript.id}`)
await manuscriptModel.update(
{
id: manuscript.id,
formState: 'No NXML file to deposit for PDF conversion',
},
adminUser.id,
)
}
}
......
Markdown is supported
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