Skip to content

Commit

Permalink
feat: Make stream stage STAGE_FOOTER when listing file has ended
Browse files Browse the repository at this point in the history
  • Loading branch information
q2s2t committed Sep 9, 2018
1 parent 70f6d72 commit aad327a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/onData.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { STAGE_HEADERS, STAGE_FILES } from './references.js'
import { STAGE_HEADERS, STAGE_FILES, STAGE_FOOTER } from './references.js'

/**
* Regexp to detect a progress vs. data
Expand Down Expand Up @@ -53,6 +53,17 @@ export function onSubprocessData (stream, chunk) {
if (matchInfo) {
stream.info[matchInfo.groups.property] = matchInfo.groups.value
}
return
}

// An empty line is created at the end of the listing of files. This empty
// line means that 7zip has reached the end of the listing, and will next
// outputs infos for the STAGE_FOOTER.
if (stream._stage === STAGE_FILES) {
const isLineEmpty = (line === '')
if (isLineEmpty) {
stream._stage = STAGE_FOOTER
}
}

// Parser function call. Only push to stream when the parser return non-null
Expand Down

0 comments on commit aad327a

Please sign in to comment.