Skip to content

Commit fd82e94

Browse files
committed
Merge PR #453 into 18.0
Signed-off-by lmignon
2 parents 3f1f424 + 84a4755 commit fd82e94

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

fs_storage/models/fs_storage.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
_logger = logging.getLogger(__name__)
2323

24+
LS_NON_EXISTING_FILE = ".NON_EXISTING_FILE"
25+
2426

2527
# TODO: useful for the whole OCA?
2628
def deprecated(reason):
@@ -296,7 +298,14 @@ def _marker_file_check_connection(self, fs):
296298
fs.touch(marker_file_name)
297299

298300
def _ls_check_connection(self, fs):
299-
fs.ls("", detail=False)
301+
# NOTE: run 'ls' on a non existing file to get better perf on FS
302+
# having a huge amount of files in root folder.
303+
# Getting a 'FileNotFoundError' means that the connection is working well.
304+
try:
305+
fs.ls(LS_NON_EXISTING_FILE, detail=False)
306+
# pylint: disable=except-pass
307+
except FileNotFoundError:
308+
pass
300309

301310
def _check_connection(self, fs, check_connection_method):
302311
if check_connection_method == "marker_file":

0 commit comments

Comments
 (0)