Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16][IMP] attachment_synchronize : add hook when pushing file to remote #3011

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading