Qubes: avoid tracebacks when no more /tmp storage

Detect OSError when writing RBG files on the Qubes isolation provider.

Fixes #578
This commit is contained in:
deeplow 2023-10-04 12:25:45 +01:00
parent 42810e0b94
commit 9fa6be9218
No known key found for this signature in database
GPG key ID: 577982871529A52A
2 changed files with 19 additions and 8 deletions

View file

@ -124,6 +124,15 @@ class ServerOutOfTempSpaceError(OutOfSpaceError):
error_message = "The isolated environment where the document conversion take space ran out of space" error_message = "The isolated environment where the document conversion take space ran out of space"
class ClientOutOfTMPSpaceError(OutOfSpaceError):
"""The client ran out of space"""
error_code = ERROR_SHIFT + 72
error_message = (
"You computer ran out of temporary storage space during the document conversion"
)
class UnexpectedConversionError(PDFtoPPMException): class UnexpectedConversionError(PDFtoPPMException):
error_code = ERROR_SHIFT + 100 error_code = ERROR_SHIFT + 100
error_message = "Some unexpected error occurred while converting the document" error_message = "Some unexpected error occurred while converting the document"

View file

@ -135,14 +135,16 @@ class Qubes(IsolationProvider):
timeout=sw.remaining, timeout=sw.remaining,
) )
# Wrapper code try:
with open(f"/tmp/dangerzone/page-{page}.width", "w") as f_width: # Wrapper code
f_width.write(str(width)) with open(f"/tmp/dangerzone/page-{page}.width", "w") as f_width:
with open(f"/tmp/dangerzone/page-{page}.height", "w") as f_height: f_width.write(str(width))
f_height.write(str(height)) with open(f"/tmp/dangerzone/page-{page}.height", "w") as f_height:
with open(f"/tmp/dangerzone/page-{page}.rgb", "wb") as f_rgb: f_height.write(str(height))
f_rgb.write(untrusted_pixels) with open(f"/tmp/dangerzone/page-{page}.rgb", "wb") as f_rgb:
f_rgb.write(untrusted_pixels)
except OSError:
raise errors.ClientOutOfTMPSpaceError()
percentage += percentage_per_page percentage += percentage_per_page
text = f"Converting page {page}/{n_pages} to pixels" text = f"Converting page {page}/{n_pages} to pixels"