diff --git a/fs_storage/models/fs_storage.py b/fs_storage/models/fs_storage.py
index 99ba816254..471bb7ad28 100644
--- a/fs_storage/models/fs_storage.py
+++ b/fs_storage/models/fs_storage.py
@@ -148,6 +148,14 @@ def __init__(self, env, ids=(), prefetch_ids=()):
compute="_compute_options_properties",
store=False,
)
+ check_connection_method = fields.Selection(
+ [
+ ("marker_file", "Create Marker file"),
+ ("ls", "List File"),
+ ],
+ default="marker_file",
+ required=True,
+ )
_sql_constraints = [
(
@@ -269,12 +277,21 @@ def _compute_options_properties(self) -> None:
def _get_marker_file_name(self):
return ".odoo_fs_storage_%s.marker" % self.id
- def _check_connection(self, fs):
+ def _marker_file_check_connection(self, fs):
marker_file_name = self._get_marker_file_name()
try:
fs.info(marker_file_name)
except FileNotFoundError:
fs.touch(marker_file_name)
+
+ def _ls_check_connection(self, fs):
+ fs.ls("", detail=False)
+
+ def _check_connection(self, fs):
+ if self.check_connection_method == "marker_file":
+ self._marker_file_check_connection(fs)
+ elif self.check_connection_method == "ls":
+ self._ls_check_connection(fs)
return True
@property
diff --git a/fs_storage/views/fs_storage_view.xml b/fs_storage/views/fs_storage_view.xml
index 3e25196230..712bb2a656 100644
--- a/fs_storage/views/fs_storage_view.xml
+++ b/fs_storage/views/fs_storage_view.xml
@@ -42,6 +42,7 @@
options="{'mode': 'python'}"
placeholder="Enter you fsspec options here."
/>
+