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 Nov 13, 2024
1 parent 0f35e5c commit 4509bd6
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 @@ -182,6 +182,13 @@ def _server_env_fields(self):
"eval_options_from_env": {},
}

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 186 in fs_storage/models/fs_storage.py

View check run for this annotation

Codecov / codecov/patch

fs_storage/models/fs_storage.py#L186

Added line #L186 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 190 in fs_storage/models/fs_storage.py

View check run for this annotation

Codecov / codecov/patch

fs_storage/models/fs_storage.py#L189-L190

Added lines #L189 - L190 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 @@ -75,6 +75,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 4509bd6

Please sign in to comment.