forked from OCA/storage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathodoo_file_system.py
50 lines (39 loc) · 1.51 KB
/
odoo_file_system.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Copyright 2023 ACSONE SA/NV (https://www.acsone.eu).
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from fsspec.registry import register_implementation
from .rooted_dir_file_system import RootedDirFileSystem
class OdooFileSystem(RootedDirFileSystem):
"""A directory-based filesystem for Odoo.
This filesystem is mounted from a specific subdirectory of the Odoo
filestore directory.
It extends the RootedDirFileSystem to avoid going outside the
specific subdirectory nor the Odoo filestore directory.
Parameters:
odoo_storage_path: The path of the subdirectory of the Odoo filestore
directory to mount. This parameter is required and is always provided
by the Odoo FS Storage even if it is explicitly defined in the
storage options.
fs: AbstractFileSystem
An instantiated filesystem to wrap.
target_protocol, target_options:
if fs is none, construct it from these
"""
def __init__(
self,
*,
odoo_storage_path,
fs=None,
target_protocol=None,
target_options=None,
**storage_options
):
if not odoo_storage_path:
raise ValueError("odoo_storage_path is required")
super().__init__(
path=odoo_storage_path,
fs=fs,
target_protocol=target_protocol,
target_options=target_options,
**storage_options
)
register_implementation("odoofs", OdooFileSystem)