Skip to content

Commit

Permalink
Merge PR OCA#3011 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by bguillot
  • Loading branch information
OCA-git-bot committed Aug 29, 2024
2 parents db9e502 + bf53ff5 commit 6d04b10
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions attachment_synchronize/models/attachment_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ class AttachmentQueue(models.Model):
selection_add=[("export", "Export File (External location)")]
)

def _write_file_to_remote(self, fs, full_path):
self.ensure_one()
data = base64.b64decode(self.datas)
with fs.open(full_path, "wb") as f:
f.write(data)

def _run(self):
res = super()._run()
if self.file_type == "export":
Expand All @@ -32,9 +38,7 @@ def _run(self):
# create missing folders if necessary :
if folder_path and not fs.exists(folder_path):
fs.makedirs(folder_path)
data = base64.b64decode(self.datas)
with fs.open(full_path, "wb") as f:
f.write(data)
self._write_file_to_remote(fs, full_path)
return res

def _get_failure_emails(self):
Expand Down

0 comments on commit 6d04b10

Please sign in to comment.