in export/securedrop_export/disk/service.py [0:0]
def export(self) -> Status:
"""
Export material to USB drive.
"""
try:
volume = self.cli.get_volume()
if isinstance(volume, MountedVolume):
logger.debug("Mounted volume detected, exporting files")
self.cli.write_data_to_device(
volume, self.submission.tmpdir, self.submission.target_dirname
)
return Status.SUCCESS_EXPORT
elif isinstance(volume, Volume):
if self.submission.encryption_key is not None:
logger.debug("Volume is locked, try unlocking")
mv = self.cli.unlock_volume(volume, self.submission.encryption_key)
if isinstance(mv, MountedVolume):
logger.debug("Export to device")
# Exports then locks the drive.
# If the export succeeds but the drive is in use, will raise
# exception.
self.cli.write_data_to_device(
mv, self.submission.tmpdir, self.submission.target_dirname
)
return Status.SUCCESS_EXPORT
else:
raise ExportException(sdstatus=Status.ERROR_UNLOCK_GENERIC)
else:
logger.info("Volume is locked and no key has been provided")
return Status.DEVICE_LOCKED
except ExportException as ex:
logger.debug(ex)
status = ex.sdstatus if ex.sdstatus is not None else Status.ERROR_EXPORT
logger.error(f"Enountered {status.value} while trying to export")
return status