/// <summary>Remove an inode from parent's children list.</summary> /// <remarks> /// Remove an inode from parent's children list. The caller of this method /// needs to make sure that parent is in the given snapshot "latest". /// </remarks> public virtual bool RemoveChild(INodeDirectory parent, INode child, int latestSnapshotId ) { // For a directory that is not a renamed node, if isInLatestSnapshot returns // false, the directory is not in the latest snapshot, thus we do not need // to record the removed child in any snapshot. // For a directory that was moved/renamed, note that if the directory is in // any of the previous snapshots, we will create a reference node for the // directory while rename, and isInLatestSnapshot will return true in that // scenario (if all previous snapshots have been deleted, isInLatestSnapshot // still returns false). Thus if isInLatestSnapshot returns false, the // directory node cannot be in any snapshot (not in current tree, nor in // previous src tree). Thus we do not need to record the removed child in // any snapshot. DirectoryWithSnapshotFeature.ChildrenDiff diff = diffs.CheckAndAddLatestSnapshotDiff (latestSnapshotId, parent).diff; Diff.UndoInfo <INode> undoInfo = diff.Delete(child); bool removed = parent.RemoveChild(child); if (!removed && undoInfo != null) { // remove failed, undo diff.UndoDelete(child, undoInfo); } return(removed); }
/// <summary>clear the created list</summary> private QuotaCounts DestroyCreatedList(BlockStoragePolicySuite bsps, INodeDirectory currentINode, INode.BlocksMapUpdateInfo collectedBlocks, IList <INode> removedINodes ) { QuotaCounts counts = new QuotaCounts.Builder().Build(); IList <INode> createdList = GetList(Diff.ListType.Created); foreach (INode c in createdList) { c.ComputeQuotaUsage(bsps, counts, true); c.DestroyAndCollectBlocks(bsps, collectedBlocks, removedINodes); // c should be contained in the children list, remove it currentINode.RemoveChild(c); } createdList.Clear(); return(counts); }