@@ -294,15 +294,9 @@ async def get_contents(self, drive_name, path):
294294
295295 # dealing with the case of an empty directory, making sure it is not an empty file
296296 if emptyDir is True :
297- ext_list = ['.R' , '.bmp' , '.csv' , '.gif' , '.html' , '.ipynb' , '.jl' , '.jpeg' , '.jpg' , '.json' , '.jsonl' , '.md' , '.ndjson' , '.pdf' , '.png' , '.py' , '.svg' , '.tif' , '.tiff' , '.tsv' , '.txt' , '.webp' , '.yaml' , '.yml' ]
298- object_name = os .path .basename (path )
299- # if object doesn't contain . or doesn't end in one of the registered extensions
300- if object_name .find ('.' ) == - 1 or ext_list .count (os .path .splitext (object_name )[1 ]) == 0 :
297+ check = await self ._check_object (drive_name , path )
298+ if check == True :
301299 data = []
302-
303- # remove upper logic once directories are fixed
304- check = self ._check_object (drive_name , path )
305- print (check )
306300
307301 response = {
308302 "data" : data
@@ -578,7 +572,7 @@ async def _get_drive_location(self, drive_name):
578572
579573 return location
580574
581- def _check_object (self , drive_name , path ):
575+ async def _check_object (self , drive_name , path ):
582576 """Helping function to check if we are dealing with an empty file or directory.
583577
584578 Args:
@@ -587,17 +581,13 @@ def _check_object(self, drive_name, path):
587581 """
588582 isDir = False
589583 try :
590- location = self ._content_managers [drive_name ]["location" ]
591- if location not in self ._s3_clients :
592- self ._s3_clients [location ] = self ._s3_session .client ('s3' , location )
593-
594- listing = self ._s3_clients [location ].list_objects_v2 (Bucket = drive_name , Prefix = path + '/' )
595- if 'Contents' in listing :
596- isDir = True
584+ response = await self ._file_system ._info (drive_name + '/' + path )
585+ if response ["type" ]== 'directory' :
586+ isDir = True
597587 except Exception as e :
598588 raise tornado .web .HTTPError (
599589 status_code = httpx .codes .BAD_REQUEST ,
600- reason = f"The following error occured when retriving the drive location : { e } " ,
590+ reason = f"The following error occured when checking the object information : { e } " ,
601591 )
602592
603593 return isDir
0 commit comments