diff --git a/dangerzone/conversion/doc_to_pixels.py b/dangerzone/conversion/doc_to_pixels.py index 236564d14..073c63fb5 100644 --- a/dangerzone/conversion/doc_to_pixels.py +++ b/dangerzone/conversion/doc_to_pixels.py @@ -349,16 +349,26 @@ async def pdftoppm_progress_callback(line: bytes) -> None: timeout=timeout, ) - self.update_progress("Converted document to pixels") - - # Move converted files into /tmp/dangerzone - for filename in ( + final_files = ( glob.glob("/tmp/page-*.rgb") + glob.glob("/tmp/page-*.width") + glob.glob("/tmp/page-*.height") - ): + ) + + # XXX: Sanity check to avoid situations like #560. + if len(final_files) != 3 * num_pages: + raise errors.UnexpectedConversionError( + "The final number of pages does not correspond to the page count of the" + " original document" + ) + + # Move converted files into /tmp/dangerzone + for filename in final_files: shutil.move(filename, "/tmp/dangerzone") + self.update_progress("Converted document to pixels") + + async def install_libreoffice_ext(self, libreoffice_ext: str) -> None: self.update_progress(f"Installing LibreOffice extension '{libreoffice_ext}'") unzip_args = [