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

Python 3.9 fixes, auth option for webdav, fixed stored filename #285

Closed
Closed
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
13 changes: 13 additions & 0 deletions fs_attachment/models/ir_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,19 @@ def _enforce_meaningful_storage_filename(self) -> None:
# we need to update the store_fname with the new filename by
# calling the write method of the field since the write method
# of ir_attachment prevent normal write on store_fname

# rooted_dir path computation...
# done by @lmignon - Laurent Mignon (ACSONE)
# there could be a nested rooted dir in the fs path - we do compute it here
# and remove it from the new_filename if it does exists
rooted_paths = []
rooted_dir_fs = fs
while rooted_dir_fs and hasattr(rooted_dir_fs, "path"):
rooted_paths.append(rooted_dir_fs.path)
rooted_dir_fs = getattr(rooted_dir_fs, "fs", None)
rooted_paths.reverse()
rooted_path = "/".join(rooted_paths)
new_filename = new_filename_with_path.replace(rooted_path, "")
attachment._force_write_store_fname(f"{storage}://{new_filename}")
self._fs_mark_for_gc(attachment.store_fname)

Expand Down
Loading