Skip to content

Commit

Permalink
[IMP] fs_storage: replace {db_name} in directory_path
Browse files Browse the repository at this point in the history
In multi database mode, there was no way to avoid filename collisions
  • Loading branch information
vincent-hatakeyama committed Jun 24, 2024
1 parent 5fe0c42 commit 9dc2fa7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions fs_storage/models/fs_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ def __init__(self, env, ids=(), prefetch_ids=()):
def _server_env_fields(self):
return {"protocol": {}, "options": {}, "directory_path": {}}

def _server_env_read_from_config(self, field_name, config_getter):
value = super()._server_env_read_from_config(field_name, config_getter)

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

View check run for this annotation

Codecov / codecov/patch

fs_storage/models/fs_storage.py#L166

Added line #L166 was not covered by tests
# replace {db_name} with the dbname
if field_name == "directory_path":
value = value.format(db_name=self.env.cr.dbname)
return value

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

View check run for this annotation

Codecov / codecov/patch

fs_storage/models/fs_storage.py#L169-L170

Added lines #L169 - L170 were not covered by tests

def write(self, vals):
self.__fs = None
self.env.registry.clear_cache()
Expand Down
2 changes: 2 additions & 0 deletions fs_storage/readme/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ for the following fields:
- options
- directory_path

When evaluating directory_path, `{db_name}` is replaced by the database name.

## Migration from storage_backend

The fs_storage addon can be used to replace the storage_backend addon.
Expand Down
1 change: 1 addition & 0 deletions fs_storage/readme/newsfragments/db_name.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Replace {db_name} by the database name in directory_path

0 comments on commit 9dc2fa7

Please sign in to comment.