deleteEntity method
Implementation
bool deleteEntity(String entityId) {
AffogatoVFSEntity parentDir = api.workspace.workspaceConfigs.vfs.root;
final AffogatoVFSEntity? result = accessEntity(
entityId,
isDir: false,
stepCallback: (currentItem) {
if (currentItem.isDirectory) parentDir = currentItem;
},
);
if (result == null) return false;
api.workspace.workspaceConfigs.vfs.bin[entityId] = result;
// Remember not to call [accessEntity] or other methods that depend on the cache
// after it has been updated.
api.workspace.workspaceConfigs.vfs.cache.remove(entityId);
if (!result.isDirectory) {
parentDir.files.remove(result);
} else {
parentDir.subdirs.remove(result);
traverseBFS(
startDirId: result.entityId,
(e) {
api.workspace.workspaceConfigs.vfs.bin[e.entityId] = e;
api.workspace.workspaceConfigs.vfs.cache.remove(e.entityId);
},
);
}
return true;
}