Skip to content

Commit 5a83c6f

Browse files
committed
remove filereadstreamcommand
1 parent fb48669 commit 5a83c6f

7 files changed

Lines changed: 29 additions & 80 deletions

File tree

frontend/app/store/wshclientapi.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,12 +366,6 @@ export class RpcApiType {
366366
return client.wshRpcCall("fileread", data, opts);
367367
}
368368

369-
// command "filereadstream" [responsestream]
370-
FileReadStreamCommand(client: WshClient, data: FileData, opts?: RpcOpts): AsyncGenerator<FileData, void, boolean> {
371-
if (this.mockClient) return this.mockClient.mockWshRpcStream(client, "filereadstream", data, opts);
372-
return client.wshRpcStream("filereadstream", data, opts);
373-
}
374-
375369
// command "filerestorebackup" [call]
376370
FileRestoreBackupCommand(client: WshClient, data: CommandFileRestoreBackupData, opts?: RpcOpts): Promise<void> {
377371
if (this.mockClient) return this.mockClient.mockWshRpcCall(client, "filerestorebackup", data, opts);

frontend/preview/mock/mockfilesystem.ts

Lines changed: 16 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,23 @@ const MockDirMimeType = "directory";
88
const MockDirMode = 0o040755;
99
const MockFileMode = 0o100644;
1010
const MockDirectoryChunkSize = 128;
11-
const MockFileChunkSize = 64 * 1024;
1211
const MockBaseModTime = Date.parse("2026-03-10T09:00:00.000Z");
1312
const TinyPngBytes = Uint8Array.from([
14-
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
15-
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x04, 0x00, 0x00, 0x00, 0xb5, 0x1c, 0x0c,
16-
0x02, 0x00, 0x00, 0x00, 0x0b, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0x63, 0xfc, 0xff, 0x1f, 0x00,
17-
0x03, 0x03, 0x01, 0xff, 0xa5, 0xf8, 0x8f, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44,
18-
0xae, 0x42, 0x60, 0x82,
13+
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00,
14+
0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x04, 0x00, 0x00, 0x00, 0xb5, 0x1c, 0x0c, 0x02, 0x00, 0x00, 0x00, 0x0b, 0x49,
15+
0x44, 0x41, 0x54, 0x78, 0xda, 0x63, 0xfc, 0xff, 0x1f, 0x00, 0x03, 0x03, 0x01, 0xff, 0xa5, 0xf8, 0x8f, 0xb1, 0x00,
16+
0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
1917
]);
2018
const TinyJpegBytes = Uint8Array.from([
21-
0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01,
22-
0x00, 0x01, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02, 0x03, 0x02, 0x02, 0x03,
23-
0x03, 0x03, 0x03, 0x04, 0x03, 0x03, 0x04, 0x05, 0x08, 0x05, 0x05, 0x04, 0x04, 0x05, 0x0a, 0x07,
24-
0x07, 0x06, 0x08, 0x0c, 0x0a, 0x0c, 0x0c, 0x0b, 0x0a, 0x0b, 0x0b, 0x0d, 0x0e, 0x12, 0x10, 0x0d,
25-
0x0e, 0x11, 0x0e, 0x0b, 0x0b, 0x10, 0x16, 0x10, 0x11, 0x13, 0x14, 0x15, 0x15, 0x15, 0x0c, 0x0f,
26-
0x17, 0x18, 0x16, 0x14, 0x18, 0x12, 0x14, 0x15, 0x14, 0xff, 0xc0, 0x00, 0x0b, 0x08, 0x00, 0x01,
27-
0x00, 0x01, 0x01, 0x01, 0x11, 0x00, 0xff, 0xc4, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
28-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xff, 0xc4, 0x00, 0x14,
29-
0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30-
0x00, 0x00, 0xff, 0xda, 0x00, 0x08, 0x01, 0x01, 0x00, 0x00, 0x3f, 0x00, 0xbf, 0xff, 0xd9,
19+
0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00,
20+
0x00, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02, 0x03, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x03, 0x03,
21+
0x04, 0x05, 0x08, 0x05, 0x05, 0x04, 0x04, 0x05, 0x0a, 0x07, 0x07, 0x06, 0x08, 0x0c, 0x0a, 0x0c, 0x0c, 0x0b, 0x0a,
22+
0x0b, 0x0b, 0x0d, 0x0e, 0x12, 0x10, 0x0d, 0x0e, 0x11, 0x0e, 0x0b, 0x0b, 0x10, 0x16, 0x10, 0x11, 0x13, 0x14, 0x15,
23+
0x15, 0x15, 0x0c, 0x0f, 0x17, 0x18, 0x16, 0x14, 0x18, 0x12, 0x14, 0x15, 0x14, 0xff, 0xc0, 0x00, 0x0b, 0x08, 0x00,
24+
0x01, 0x00, 0x01, 0x01, 0x01, 0x11, 0x00, 0xff, 0xc4, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xff, 0xc4, 0x00, 0x14, 0x10, 0x01, 0x00, 0x00, 0x00,
26+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xda, 0x00, 0x08, 0x01, 0x01,
27+
0x00, 0x00, 0x3f, 0x00, 0xbf, 0xff, 0xd9,
3128
]);
3229

3330
type MockFsEntry = {
@@ -61,7 +58,6 @@ export type MockFilesystem = {
6158
fileRead: (data: FileData) => Promise<FileData>;
6259
fileList: (data: FileListData) => Promise<FileInfo[]>;
6360
fileJoin: (paths: string[]) => Promise<FileInfo>;
64-
fileReadStream: (data: FileData) => AsyncGenerator<FileData, void, boolean>;
6561
fileListStream: (data: FileListData) => AsyncGenerator<CommandRemoteListEntriesRtnData, void, boolean>;
6662
};
6763

@@ -492,33 +488,9 @@ export function makeMockFilesystem(): MockFilesystem {
492488
}
493489
return toFileInfo(entry);
494490
};
495-
const fileReadStream = async function* (data: FileData): AsyncGenerator<FileData, void, boolean> {
496-
const info = await fileInfo(data);
497-
yield { info };
498-
if (info.notfound) {
499-
return;
500-
}
501-
const entry = getEntry(info.path);
502-
if (entry.isdir) {
503-
const dirEntries = (childrenByDir.get(entry.path) ?? []).map((child) => toFileInfo(child));
504-
for (let idx = 0; idx < dirEntries.length; idx += MockDirectoryChunkSize) {
505-
yield { entries: dirEntries.slice(idx, idx + MockDirectoryChunkSize) };
506-
}
507-
return;
508-
}
509-
if (entry.content == null || entry.content.byteLength === 0) {
510-
return;
511-
}
512-
const { offset, end } = getReadRange(data, entry.content.byteLength);
513-
for (let currentOffset = offset; currentOffset < end; currentOffset += MockFileChunkSize) {
514-
const chunkEnd = Math.min(currentOffset + MockFileChunkSize, end);
515-
yield {
516-
data64: arrayToBase64(entry.content.slice(currentOffset, chunkEnd)),
517-
at: { offset: currentOffset, size: chunkEnd - currentOffset },
518-
};
519-
}
520-
};
521-
const fileListStream = async function* (data: FileListData): AsyncGenerator<CommandRemoteListEntriesRtnData, void, boolean> {
491+
const fileListStream = async function* (
492+
data: FileListData
493+
): AsyncGenerator<CommandRemoteListEntriesRtnData, void, boolean> {
522494
const fileInfos = await fileList(data);
523495
for (let idx = 0; idx < fileInfos.length; idx += MockDirectoryChunkSize) {
524496
yield { fileinfo: fileInfos.slice(idx, idx + MockDirectoryChunkSize) };
@@ -535,7 +507,6 @@ export function makeMockFilesystem(): MockFilesystem {
535507
fileRead,
536508
fileList,
537509
fileJoin,
538-
fileReadStream,
539510
fileListStream,
540511
};
541512
}

frontend/preview/mock/mockwaveenv.test.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { base64ToArray, base64ToString } from "@/util/util";
1+
import { base64ToString } from "@/util/util";
22
import { describe, expect, it, vi } from "vitest";
33
import { DefaultMockFilesystem } from "./mockfilesystem";
44

@@ -82,26 +82,19 @@ describe("makeMockWaveEnv", () => {
8282
}
8383
expect(listPackets).toHaveLength(1);
8484
expect(listPackets[0].fileinfo).toHaveLength(4);
85-
86-
const readPackets: FileData[] = [];
87-
for await (const packet of env.rpc.FileReadStreamCommand(null as any, {
88-
info: { path: "/Users/mike/Pictures/beach-sunrise.png" },
89-
})) {
90-
readPackets.push(packet);
91-
}
92-
expect(readPackets[0].info?.path).toBe("/Users/mike/Pictures/beach-sunrise.png");
93-
const imageBytes = base64ToArray(readPackets[1].data64);
94-
expect(Array.from(imageBytes.slice(0, 4))).toEqual([0x89, 0x50, 0x4e, 0x47]);
9585
});
9686

9787
it("implements secrets commands with in-memory storage", async () => {
9888
const { makeMockWaveEnv } = await import("./mockwaveenv");
9989
const env = makeMockWaveEnv({ platform: "linux" });
10090

101-
await env.rpc.SetSecretsCommand(null as any, {
102-
OPENAI_API_KEY: "sk-test",
103-
ANTHROPIC_API_KEY: "anthropic-test",
104-
} as any);
91+
await env.rpc.SetSecretsCommand(
92+
null as any,
93+
{
94+
OPENAI_API_KEY: "sk-test",
95+
ANTHROPIC_API_KEY: "anthropic-test",
96+
} as any
97+
);
10598

10699
expect(await env.rpc.GetSecretsLinuxStorageBackendCommand(null as any)).toBe("libsecret");
107100
expect(await env.rpc.GetSecretsNamesCommand(null as any)).toEqual(["ANTHROPIC_API_KEY", "OPENAI_API_KEY"]);

frontend/preview/mock/mockwaveenv.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,6 @@ export function makeMockRpc(
310310
setCallHandler("fileread", async (_client, data: FileData) => DefaultMockFilesystem.fileRead(data));
311311
setCallHandler("filelist", async (_client, data: FileListData) => DefaultMockFilesystem.fileList(data));
312312
setCallHandler("filejoin", async (_client, data: string[]) => DefaultMockFilesystem.fileJoin(data));
313-
setStreamHandler("filereadstream", async function* (_client, data: FileData) {
314-
yield* DefaultMockFilesystem.fileReadStream(data);
315-
});
316313
setStreamHandler("fileliststream", async function* (_client, data: FileListData) {
317314
yield* DefaultMockFilesystem.fileListStream(data);
318315
});
@@ -461,7 +458,11 @@ export function makeMockWaveEnv(mockEnv?: MockEnv): MockWaveEnv {
461458
globalStore.set(waveObjectValueAtomCache.get(oref), obj);
462459
},
463460
};
464-
const { rpc, setRpcHandler, setRpcStreamHandler } = makeMockRpc(mergedOverrides.rpc, mergedOverrides.rpcStreaming, mockWosFns);
461+
const { rpc, setRpcHandler, setRpcStreamHandler } = makeMockRpc(
462+
mergedOverrides.rpc,
463+
mergedOverrides.rpcStreaming,
464+
mockWosFns
465+
);
465466
const env = {
466467
isMock: true,
467468
mockEnv: mergedOverrides,

pkg/wshrpc/wshclient/wshclient.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,6 @@ func FileReadCommand(w *wshutil.WshRpc, data wshrpc.FileData, opts *wshrpc.RpcOp
364364
return resp, err
365365
}
366366

367-
// command "filereadstream", wshserver.FileReadStreamCommand
368-
func FileReadStreamCommand(w *wshutil.WshRpc, data wshrpc.FileData, opts *wshrpc.RpcOpts) chan wshrpc.RespOrErrorUnion[wshrpc.FileData] {
369-
return sendRpcRequestResponseStreamHelper[wshrpc.FileData](w, "filereadstream", data, opts)
370-
}
371-
372367
// command "filerestorebackup", wshserver.FileRestoreBackupCommand
373368
func FileRestoreBackupCommand(w *wshutil.WshRpc, data wshrpc.CommandFileRestoreBackupData, opts *wshrpc.RpcOpts) error {
374369
_, err := sendRpcRequestCallHelper[any](w, "filerestorebackup", data, opts)

pkg/wshrpc/wshrpctypes_file.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ type WshRpcFileInterface interface {
1818
FileAppendCommand(ctx context.Context, data FileData) error
1919
FileWriteCommand(ctx context.Context, data FileData) error
2020
FileReadCommand(ctx context.Context, data FileData) (*FileData, error)
21-
FileReadStreamCommand(ctx context.Context, data FileData) <-chan RespOrErrorUnion[FileData]
2221
FileMoveCommand(ctx context.Context, data CommandFileCopyData) error
2322
FileCopyCommand(ctx context.Context, data CommandFileCopyData) error
2423
FileInfoCommand(ctx context.Context, data FileData) (*FileInfo, error)

pkg/wshrpc/wshserver/wshserver.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,6 @@ func (ws *WshServer) FileReadCommand(ctx context.Context, data wshrpc.FileData)
388388
return wshfs.Read(ctx, data)
389389
}
390390

391-
func (ws *WshServer) FileReadStreamCommand(ctx context.Context, data wshrpc.FileData) <-chan wshrpc.RespOrErrorUnion[wshrpc.FileData] {
392-
return wshfs.ReadStream(ctx, data)
393-
}
394-
395391
func (ws *WshServer) FileStreamCommand(ctx context.Context, data wshrpc.CommandFileStreamData) (*wshrpc.FileInfo, error) {
396392
return wshfs.FileStream(ctx, data)
397393
}

0 commit comments

Comments
 (0)