add method
Add a non existing node to the storage backend.
@param node the node to be added to the backend @throws StorageException if the node already exists, the parental node does not exist, or the backend storage encountered a problem
Implementation
@override
Future<void> add(Node node) async {
checkPath(node.path);
if (nodes[node.path] != null && nodes[node.path]!.tombstone == false) {
throw StorageException('Node does already exist');
}
if (node.skeleton) {
throw StorageException('Skeleton nodes cannot be added.');
}
String? pname = node.parentPath == '' ? ':' : node.parentPath;
if (node.parentPath != null) {
if (nodes[pname] == null) {
throw StorageException(
('Parent node "' + (node.parentPath!)) + '" does not exist');
}
await nodes[pname]?.addChild(node);
}
nodes[node.path] = await node.shallowClone();
// add children if not skeletonized (not needed... covered by controller)
//for (Node n in (await node.getChildren()).values) {
// if (!n.skeleton) {
// add(n);
// }
//}
}