async cleanBucket()

in util/upload/src/lib/minio.ts [37:60]


    async cleanBucket(): Promise<void> {
        try {
            // List all objects in the bucket
            const objectsStream = this.minioClient.listObjectsV2(this.bucket, '', true);

            const objectNames: string[] = [];
            for await (const obj of objectsStream) {
                objectNames.push(obj.name); // Collect object names to delete
            }

            if (objectNames.length > 0) {
                // Delete objects in batches
                await this.minioClient.removeObjects(this.bucket, objectNames);
                if (this.programOptions["--verbose"])
                    console.log(`${objectNames.length} objects removed from bucket ${this.bucket}.`);
            } else {
                if (this.programOptions["--verbose"])
                    console.log(`No objects found in bucket ${this.bucket}.`);
            }
        } catch (err) {
            console.error(`Failed to clean bucket ${this.bucket}:`, err);
            throw err;
        }
    }