From 292d9fea0bfdfb7de1454a45db912e3c8e587f6f Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Thu, 5 Sep 2024 17:49:57 +0200 Subject: [PATCH] [IMP] attachment synchronize Use cat_file It was like this before and it is now supported by sshfs. open + read is slower and less reliable --- .../models/attachment_synchronize_task.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/attachment_synchronize/models/attachment_synchronize_task.py b/attachment_synchronize/models/attachment_synchronize_task.py index 3f97e7c83..8b060600f 100644 --- a/attachment_synchronize/models/attachment_synchronize_task.py +++ b/attachment_synchronize/models/attachment_synchronize_task.py @@ -211,11 +211,7 @@ class AttachmentSynchronizeTask(models.Model): with self.env.registry.cursor() as new_cr: new_env = api.Environment(new_cr, self.env.uid, self.env.context) file_name = file_path.split(fs.sep)[-1] - # avoid use of cat_file because it may not be implemeted in async - # implementation like sshfs - with fs.open(file_path, "rb") as fs_file: - data = fs_file.read() - data = base64.b64encode(data) + data = base64.b64encode(fs.cat_file(file_path)) attach_vals = self.with_env(new_env)._prepare_attachment_vals( data, file_name )