mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-24 16:48:36 +00:00
Merge commit 'refs/pull/114/head' of github.com:camptocamp/odoo-cloud-platform into merge-branch-2660-des-74-80_fix_filestore_images-b3ab4f63
This commit is contained in:
@@ -83,8 +83,9 @@ class IrAttachment(osv.osv):
|
|||||||
else:
|
else:
|
||||||
return super(IrAttachment, self)._store_file_read(fname, bin_size)
|
return super(IrAttachment, self)._store_file_read(fname, bin_size)
|
||||||
|
|
||||||
def _store_file_write(self, storage, key, bin_data):
|
def _store_file_write(self, storage, key, bin_data, container=None):
|
||||||
if storage == 'swift':
|
if storage == 'swift':
|
||||||
|
if container is None:
|
||||||
container = os.environ.get('SWIFT_WRITE_CONTAINER')
|
container = os.environ.get('SWIFT_WRITE_CONTAINER')
|
||||||
conn = self._get_swift_connection()
|
conn = self._get_swift_connection()
|
||||||
conn.put_container(container)
|
conn.put_container(container)
|
||||||
@@ -101,13 +102,15 @@ class IrAttachment(osv.osv):
|
|||||||
filename = _super._store_file_write(key, bin_data)
|
filename = _super._store_file_write(key, bin_data)
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
def _store_file_delete(self, fname):
|
def _store_file_delete(self, fname, container=None):
|
||||||
if fname.startswith('swift://'):
|
if fname.startswith('swift://'):
|
||||||
swifturi = SwiftUri(fname)
|
swifturi = SwiftUri(fname)
|
||||||
container = swifturi.container()
|
uri_container = swifturi.container()
|
||||||
|
if container is None:
|
||||||
|
container = os.environ.get('SWIFT_WRITE_CONTAINER')
|
||||||
# delete the file only if it is on the current configured bucket
|
# delete the file only if it is on the current configured bucket
|
||||||
# otherwise, we might delete files used on a different environment
|
# otherwise, we might delete files used on a different environment
|
||||||
if container == os.environ.get('SWIFT_WRITE_CONTAINER'):
|
if uri_container == container:
|
||||||
conn = self._get_swift_connection()
|
conn = self._get_swift_connection()
|
||||||
try:
|
try:
|
||||||
conn.delete_object(container, swifturi.item())
|
conn.delete_object(container, swifturi.item())
|
||||||
|
|||||||
Reference in New Issue
Block a user