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

18.0 add helper functions #444

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
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
8 changes: 3 additions & 5 deletions fs_attachment/models/ir_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,9 @@
return b""

def _storage_write_option(self, fs):
_fs = fs
while _fs:
if hasattr(_fs, "s3"):
return {"ContentType": self._context["mimetype"]}
_fs = getattr(_fs, "fs", None)
root_fs = self.env["fs.storage"]._get_root_filesystem(fs)
if hasattr(root_fs, "s3"):
return {"ContentType": self._context["mimetype"]}

Check warning on line 383 in fs_attachment/models/ir_attachment.py

View check run for this annotation

Codecov / codecov/patch

fs_attachment/models/ir_attachment.py#L383

Added line #L383 was not covered by tests
return {}

@api.model
Expand Down
8 changes: 8 additions & 0 deletions fs_storage/models/fs_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,3 +511,11 @@
"sticky": False,
},
}

def _get_root_filesystem(self, fs=None):
if not fs:
self.ensure_one()
fs = self.fs

Check warning on line 518 in fs_storage/models/fs_storage.py

View check run for this annotation

Codecov / codecov/patch

fs_storage/models/fs_storage.py#L517-L518

Added lines #L517 - L518 were not covered by tests
while hasattr(fs, "fs"):
fs = fs.fs
return fs