File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -294,6 +294,30 @@ def _get_drive_location(self, drive_name):
294294
295295 return location
296296
297+ def _check_object (self , drive_name , path ):
298+ """Helping function to check if we are dealing with an empty file or directory.
299+
300+ Args:
301+ drive_name: name of drive where object exists
302+ path: path to object to check
303+ """
304+ isDir = False
305+ try :
306+ location = self ._content_managers [drive_name ]["location" ]
307+ if location not in self ._s3_clients :
308+ self ._s3_clients [location ] = self ._s3_session .client ('s3' , location )
309+
310+ listing = self ._s3_clients [location ].list_objects_v2 (Bucket = drive_name , Prefix = path + '/' )
311+ if 'Contents' in listing :
312+ isDir = True
313+ except Exception as e :
314+ raise tornado .web .HTTPError (
315+ status_code = httpx .codes .BAD_REQUEST ,
316+ reason = f"The following error occured when retriving the drive location: { e } " ,
317+ )
318+
319+ return isDir
320+
297321 async def _call_provider (
298322 self ,
299323 url : str ,
You can’t perform that action at this time.
0 commit comments