Skip to content

Commit

Permalink
Trata DarwinCores com apenas uma extensão
Browse files Browse the repository at this point in the history
Fixes #58
  • Loading branch information
Phenome committed Dec 23, 2023
1 parent ed553a6 commit 08b00c0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/lib/dwca.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,10 @@ export const buildSqlite = async (folder: string, chunkSize = 5000) => {
}
const ref = {
core: _parseJsonEntry(archive.core),
extensions: archive.extension?.map(_parseJsonEntry) ?? []
extensions: (Array.isArray(archive.extension)
? archive.extension
: [archive.extension].filter(Boolean)
).map(_parseJsonEntry)
}
const multibar = new cliProgress.MultiBar(
{
Expand All @@ -195,7 +198,7 @@ export const buildSqlite = async (folder: string, chunkSize = 5000) => {
)
const b1 = multibar.create(ref.extensions.length + 1, 0)
let lineCount = 0
await streamProcessor(`${folder}/${ref.core.file}`, (line) => {
await streamProcessor(`${folder}/${ref.core.file}`, (_line) => {
lineCount++
})
const b2 = multibar.create(lineCount, 0, { filename: ref.core.file })
Expand All @@ -211,7 +214,7 @@ export const buildSqlite = async (folder: string, chunkSize = 5000) => {
db.execute(`CREATE INDEX idx_${tableName}_id ON ${tableName} (id)`)
b1.increment(1, { filename: extension.file })
let lineCount = 0
await streamProcessor(`${folder}/${extension.file}`, (line) => {
await streamProcessor(`${folder}/${extension.file}`, (_line) => {
lineCount++
})
b2.setTotal(lineCount)
Expand Down

0 comments on commit 08b00c0

Please sign in to comment.