@@ -45,12 +45,10 @@ def _ensure_folder_exists(self, path):
4545 folder_path = path .rsplit ('/' , 1 )[0 ] + '/'
4646 try :
4747 # Check if folder exists by listing with prefix
48- folders = self ._get_storage ().list (path = folder_path , limit = 1 )
49- if not folders :
50- # Create folder with an empty placeholder file
51- self ._get_storage ().upload (folder_path + '.placeholder' , b'' )
48+ folders = self ._get_storage ().list (path = folder_path )
49+ # If we get here, the folder likely exists already
5250 except StorageException :
53- # Create folder with an empty placeholder file
51+ # Try to create the folder with an empty placeholder file
5452 try :
5553 self ._get_storage ().upload (folder_path + '.placeholder' , b'' )
5654 except StorageException as e :
@@ -98,7 +96,7 @@ def exists(self, name):
9896 folder_path = name .rsplit ('/' , 1 )[0 ]
9997 filename = name .split ('/' )[- 1 ]
10098 # List files in the specific folder
101- files = self ._get_storage ().list (path = folder_path )
99+ files = self ._get_storage ().list (folder_path )
102100 else :
103101 # Files at bucket root
104102 files = self ._get_storage ().list ()
@@ -138,7 +136,7 @@ def size(self, name):
138136 folder_path = name .rsplit ('/' , 1 )[0 ]
139137 filename = name .split ('/' )[- 1 ]
140138 # List files in the specific folder
141- files = self ._get_storage ().list (path = folder_path )
139+ files = self ._get_storage ().list (folder_path )
142140 else :
143141 # Files at bucket root
144142 files = self ._get_storage ().list ()
0 commit comments