Open denizparlak1 opened 3 weeks ago
def delete_files_by_prefix(self, prefix: str): try: objects_to_delete = self.client.list_objects_v2(Bucket=self.bucket_name, Prefix=prefix) if 'Contents' in objects_to_delete: delete_keys = [{'Key': obj['Key']} for obj in objects_to_delete['Contents']] self.client.delete_objects(Bucket=self.bucket_name, Delete={'Objects': delete_keys}) return True except Exception as e: raise Exception(f"S3 Error during deletion by prefix: {e}")
The function must change sync to async to prevent lock for multiple users.