Skip to content

Commit

Permalink
Improve EOF detection when reading command output
Browse files Browse the repository at this point in the history
Do not read a line from the command output and then check if
we are at EOF, because it's possible that the writer immediately exited
after writing the last line of output. Instead, switch the order of
actions.

This is a very serious bug that can lead to Dangerzone excluding the
last page of the document. It should have bit us right from the start
(see aeeed41), but it seems that the
small period of time it takes the kernel to close the file descriptors
was hiding this bug.

Fixes #560
  • Loading branch information
apyrgio committed Sep 28, 2023
1 parent 79c1d6d commit 6012cd1
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions dangerzone/conversion/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ async def read_stream(
if they know its encoding.
"""
buf = b""
while True:
while not sr.at_eof():
line = await sr.readline()
if sr.at_eof():
break
self.captured_output += line
if callback is not None:
callback(line)
Expand Down

0 comments on commit 6012cd1

Please sign in to comment.