rethinks commited on
Commit
50ace00
·
verified ·
1 Parent(s): 9899448

Upload supabase_storage.py

Browse files
Files changed (1) hide show
  1. supabase_storage.py +9 -6
supabase_storage.py CHANGED
@@ -306,15 +306,18 @@ def delete_dataset_from_supabase(dataset_name: str) -> bool:
306
  return False
307
 
308
  try:
309
- # List all files in the dataset folder
310
- files = client.storage.from_(BUCKET_NAME).list(dataset_name)
 
 
 
311
 
312
  # Delete each file
313
  file_paths = [f"{dataset_name}/{f['name']}" for f in files if f.get('name')]
314
 
315
  if file_paths:
316
- client.storage.from_(BUCKET_NAME).remove(file_paths)
317
- print(f"[Supabase] Deleted {len(file_paths)} files from '{dataset_name}'")
318
 
319
  # Remove from registry
320
  _update_dataset_registry(client, dataset_name, action='remove')
@@ -342,8 +345,8 @@ def check_dataset_exists_in_supabase(dataset_name: str) -> bool:
342
  return False
343
 
344
  try:
345
- # Try to list files in the dataset folder
346
- files = client.storage.from_(BUCKET_NAME).list(dataset_name)
347
  return len(files) > 0
348
  except:
349
  return False
 
306
  return False
307
 
308
  try:
309
+ storage = client.storage.from_(BUCKET_NAME)
310
+
311
+ # List all files in the dataset folder (need limit option for SDK to work)
312
+ files = storage.list(path=dataset_name, options={"limit": 1000})
313
+ print(f"[Supabase] Found {len(files)} files in '{dataset_name}' to delete")
314
 
315
  # Delete each file
316
  file_paths = [f"{dataset_name}/{f['name']}" for f in files if f.get('name')]
317
 
318
  if file_paths:
319
+ result = storage.remove(file_paths)
320
+ print(f"[Supabase] Deleted {len(file_paths)} files from '{dataset_name}': {result}")
321
 
322
  # Remove from registry
323
  _update_dataset_registry(client, dataset_name, action='remove')
 
345
  return False
346
 
347
  try:
348
+ # Try to list files in the dataset folder (need limit option for SDK to work)
349
+ files = client.storage.from_(BUCKET_NAME).list(path=dataset_name, options={"limit": 1000})
350
  return len(files) > 0
351
  except:
352
  return False