deleteModel method
Permanently deletes spec's model files from disk — the GGUF and its
sibling tokenizer.json — reclaiming the ~1.1 GB the install occupies.
Returns the number of bytes actually freed. Idempotent: deleting when nothing is on disk is a no-op that returns 0. Throws SyniInstallException if a file exists but cannot be removed.
This is the real counterpart to ensureModel — SyniAgent.uninstall()
only frees the in-memory engine and leaves the download on disk.
Implementation
Future<int> deleteModel(SyniModelSpec spec) async {
final dir = await _modelsDir();
final freed = await installedBytes(spec);
for (final file in [
File('${dir.path}/${spec.filename}'),
File('${dir.path}/tokenizer.json'),
]) {
if (file.existsSync()) {
try {
file.deleteSync();
} catch (e) {
throw SyniInstallException(
'failed to delete model file ${file.path}: $e',
);
}
}
}
return freed;
}