mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-24 08:47:40 +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
|
@api.model
|
||||||
def _file_read_s3(self, fname, bin_size=False):
|
def _file_read_s3(self, fname, bin_size=False):
|
||||||
s3uri = S3Uri(fname)
|
s3uri = S3Uri(fname)
|
||||||
|
try:
|
||||||
bucket = self._get_s3_bucket(name=s3uri.bucket())
|
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())
|
filekey = bucket.get_key(s3uri.item())
|
||||||
if filekey:
|
if filekey:
|
||||||
read = base64.b64encode(filekey.get_contents_as_string())
|
read = base64.b64encode(filekey.get_contents_as_string())
|
||||||
else:
|
else:
|
||||||
read = ''
|
read = ''
|
||||||
_logger.info("_read_file_s3 reading %s, file missing", fname)
|
_logger.info("attachment '%s' missing on object storage", fname)
|
||||||
return read
|
return read
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
|
|||||||
Reference in New Issue
Block a user