cleanupStorage method
Clean up orphaned files
⚠️ This deletes files! Call getOrphanedFiles() first to see what will be deleted.
Returns number of deleted files.
Implementation
@override
Future<int> cleanupStorage() async {
await _ensureInitialized();
gemmaLog('UnifiedModelManager: Cleaning up storage (explicit user call)');
// Propagate real errors instead of returning 0: this is a destructive op,
// and a mid-sweep failure that already deleted some files must not report
// as "0 removed" (indistinguishable from "nothing to clean").
final protectedFiles = await _getProtectedFiles();
final deletedCount = await ModelFileSystemManager.cleanupOrphanedFiles(
protectedFiles: protectedFiles,
enableResumeDetection: true,
);
gemmaLog('UnifiedModelManager: Cleaned up $deletedCount orphaned files');
return deletedCount;
}