mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-24 02:08:36 +00:00
Do not fail when an attachment cannot be read
It would be blocking and a missing attachment might be a minor issue. Only warn when such a file is missing.
This commit is contained in:
@@ -91,13 +91,19 @@ class IrAttachment(models.Model):
|
||||
@api.model
|
||||
def _file_read_s3(self, fname, bin_size=False):
|
||||
s3uri = S3Uri(fname)
|
||||
bucket = self._get_s3_bucket(name=s3uri.bucket())
|
||||
try:
|
||||
bucket = self._get_s3_bucket(name=s3uri.bucket())
|
||||
except exceptions.UserError:
|
||||
_logger.exception(
|
||||
"error reading attachment '%s' from object storage", fname
|
||||
)
|
||||
return ''
|
||||
filekey = bucket.get_key(s3uri.item())
|
||||
if filekey:
|
||||
read = base64.b64encode(filekey.get_contents_as_string())
|
||||
else:
|
||||
read = ''
|
||||
_logger.info("_read_file_s3 reading %s, file missing", fname)
|
||||
_logger.info("attachment '%s' missing on object storage", fname)
|
||||
return read
|
||||
|
||||
@api.model
|
||||
|
||||
Reference in New Issue
Block a user