Improve EOF detection when reading command output

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 aeeed411a0), but it seems that the
small period of time it takes the kernel to close the file descriptors
was hiding this bug.

Fixes #560
This commit is contained in:
Alex Pyrgiotis 2023-09-26 19:34:58 +03:00
parent 79c1d6db0f
commit 6012cd1491
No known key found for this signature in database
GPG key ID: B6C15EBA0357C9AA

View file

@ -63,10 +63,8 @@ class DangerzoneConverter:
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)