@@ -296,7 +296,16 @@ def _dir_model(self, path, content=True):
296
296
model ["size" ] = None
297
297
os_dir = self ._get_os_path (path )
298
298
dir_contents = os .listdir (os_dir )
299
- model ["item_count" ] = len (dir_contents )
299
+ filtered_count = 0
300
+ for name in dir_contents :
301
+ try :
302
+ os_path = os .path .join (os_dir , name )
303
+ if self .should_list (name ) and (self .allow_hidden or not is_file_hidden (os_path )):
304
+ filtered_count += 1
305
+ except OSError as e :
306
+ self .log .warning ("Error accessing %s: %s" , os .path .join (os_dir , name ), e )
307
+
308
+ model ["item_count" ] = filtered_count
300
309
if content :
301
310
model ["content" ] = contents = []
302
311
for name in os .listdir (os_dir ):
@@ -770,7 +779,16 @@ async def _dir_model(self, path, content=True):
770
779
model ["size" ] = None
771
780
os_dir = self ._get_os_path (path )
772
781
dir_contents = await run_sync (os .listdir , os_dir )
773
- model ["item_count" ] = len (dir_contents )
782
+ filtered_count = 0
783
+ for name in dir_contents :
784
+ try :
785
+ os_path = os .path .join (os_dir , name )
786
+ if self .should_list (name ) and (self .allow_hidden or not is_file_hidden (os_path )):
787
+ filtered_count += 1
788
+ except OSError as e :
789
+ self .log .warning ("Error accessing %s: %s" , os .path .join (os_dir , name ), e )
790
+
791
+ model ["item_count" ] = filtered_count
774
792
if content :
775
793
model ["content" ] = contents = []
776
794
for name in dir_contents :
0 commit comments