File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121
2222_logger = logging .getLogger (__name__ )
2323
24+ LS_NON_EXISTING_FILE = ".NON_EXISTING_FILE"
25+
2426
2527# TODO: useful for the whole OCA?
2628def 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" :
You can’t perform that action at this time.
0 commit comments