def export()

in client/securedrop_client/export.py [0:0]


    def export(self, filepaths: list[str], passphrase: str | None) -> None:
        """
        Bundle filepaths into a tarball and send to encrypted USB via qrexec,
        optionally supplying a passphrase to unlock encrypted drives.
        """
        try:
            logger.debug(f"Begin exporting {len(filepaths)} item(s)")

            # Edit metadata template to include passphrase
            metadata = self._DISK_METADATA.copy()
            if passphrase:
                metadata[self._DISK_ENCRYPTION_KEY_NAME] = passphrase

            self.tmpdir = mkdtemp()
            os.chmod(self.tmpdir, 0o700)

            archive_path = self._create_archive(
                archive_dir=self.tmpdir,
                archive_fn=self._DISK_FN,
                metadata=metadata,
                filepaths=filepaths,
            )

            # Emits status through callbacks
            self._run_qrexec_export(
                archive_path, self._on_export_process_complete, self._on_export_process_error
            )

        except OSError as e:
            logger.error("Export failed")
            logger.debug(f"Export failed: {e}")
            self.export_state_changed.emit(ExportStatus.ERROR_EXPORT)

        # ExportStatus.ERROR_MISSING_FILES
        except ExportError as err:
            if err.status:
                logger.error("Export failed while creating archive")
                self.export_state_changed.emit(err.status)
            else:
                logger.error("Export failed while creating archive (no status supplied)")
                self.export_state_changed.emit(ExportStatus.ERROR_EXPORT)