- Cleaned up old tests

- Changed `node:buffer` and `node:streams` imports to native `WebWorkers` imports;
- Fixed tests that used old `toPtr` and `fromPtr` functions to use the new NodePointer class methods
- Exposed pointer resolution helper functions to the consumer
This commit is contained in:
2026-11-20 12:22:23 +01:00
parent 2cf84ccd2f
commit d825299e26
20 changed files with 152 additions and 738 deletions
+2 -4
View File
@@ -1,8 +1,6 @@
import type { UserInfo } from "@core/session_manager";
import { upTraverseTree } from "@core/util/tree_traversal";
import { VDiskManager } from "@core/util/vdisk_manager";
import type { Blob } from "node:buffer";
import type { Readable } from "node:stream";
import type {
AlreadyExistsError,
DeviceNotFoundError,
@@ -379,7 +377,7 @@ export class FileSystem {
mode: number;
owner: number;
group: number;
content: Blob | Readable;
content: Blob | ReadableStream;
size: number;
}
| { type: NodeType.Directory; mode: number; owner: number; group: number }
@@ -507,7 +505,7 @@ export class FileSystem {
await dev.writeContent((node as FileNode).content, content);
}
public streamContent(target: NodePointer): Readable {
public streamContent(target: NodePointer): ReadableStream {
const dev = this._VDiskManager.getDisk(target.device);
const node = this.resolveNode(target);
+7 -7
View File
@@ -1,6 +1,3 @@
import type { Blob } from "node:buffer";
import { Readable } from "node:stream";
import { blob } from "node:stream/consumers";
import { NodePointer, NodeType, type DirectoryNode, type Node, type NodeEntry, type NodeHash } from "./node";
export function DefaultVDiskConfig(id: number): VDiskConfig {
@@ -53,7 +50,7 @@ export interface DataConfig {
export interface IDataStore {
read(uuid: string): Promise<Uint8Array>;
stream(uuid: string): Readable;
stream(uuid: string): ReadableStream;
put(uuid: string, blob: Blob): Promise<void>;
delete(uuid: string): Promise<void>;
has(uuid: string): Promise<boolean>;
@@ -210,7 +207,7 @@ export class VDisk {
mode: number;
owner: number;
group: number;
content: Blob | Readable;
content: Blob | ReadableStream;
size: number;
}
| { type: NodeType.Directory; mode: number; owner: number; group: number }
@@ -241,7 +238,10 @@ export class VDisk {
switch (data.type) {
case NodeType.File:
node = { ...base, type: NodeType.File, content: uuid, size: data.size };
this.writeContent(uuid, data.content instanceof Readable ? await blob(data.content) : data.content);
this.writeContent(
uuid,
data.content instanceof ReadableStream ? await new Response(data.content).blob() : data.content,
);
break;
case NodeType.Directory:
node = { ...base, type: NodeType.Directory, children: new Map() };
@@ -391,7 +391,7 @@ export class VDisk {
return this._dataStore.read(uuid);
}
public streamContent(uuid: string): Readable {
public streamContent(uuid: string): ReadableStream {
return this._dataStore.stream(uuid);
}