- fixed a bug in *sort.ts* where passed number arrays wouldnt get properly parsed into TreeNode arrays
- excluded inode 0 from tree traversal results
This commit is contained in:
@@ -23,7 +23,7 @@ export function sortTreeNodes<T extends TreeNode | number>(
|
||||
|
||||
const nodes: TreeNode[] = [];
|
||||
|
||||
if (typeof arr === "number") {
|
||||
if (typeof arr[0] === "number") {
|
||||
for (const e of arr as number[]) {
|
||||
const node = state.filesystem.getNode(e);
|
||||
if (!node) continue;
|
||||
@@ -36,7 +36,7 @@ export function sortTreeNodes<T extends TreeNode | number>(
|
||||
|
||||
nodeQS(nodes, r, by, 0, nodes.length - 1);
|
||||
|
||||
if (typeof arr === "number") {
|
||||
if (typeof arr[0] === "number") {
|
||||
return nodes.map(n => n.inode) as T[];
|
||||
} else {
|
||||
return nodes as T[];
|
||||
@@ -90,6 +90,7 @@ function compareTreeNode(a: TreeNode, b: TreeNode, by: SortTreeNodeBy, r: boolea
|
||||
|
||||
return r ? B.length - A.length : A.length - B.length;
|
||||
}
|
||||
|
||||
case SortTreeNodeBy.MTIME:
|
||||
case SortTreeNodeBy.ATIME:
|
||||
case SortTreeNodeBy.CTIME: {
|
||||
|
||||
@@ -11,7 +11,7 @@ export function dnTraverseTree(fs: FileSystem, root: number): number[] {
|
||||
const node = fs.getNode(stack.pop() as number);
|
||||
if (node === undefined) continue;
|
||||
|
||||
result.push(node.inode);
|
||||
if (node.inode !== 0) result.push(node.inode);
|
||||
|
||||
if (node.type === TreeNodeType.Directory) {
|
||||
const children = Object.values(node.children);
|
||||
|
||||
Reference in New Issue
Block a user