refactor(share): make saveFile content nullable for path-based shares (#4424)
The book "Send" flow had to pass `new ArrayBuffer(0)` to saveFile purely to satisfy the type-checker: the content arg is ignored on the native share path when `options.filePath` points at an already-on-disk file. Widen saveFile's content parameter to `string | ArrayBuffer | null` across the AppService contract so callers can hand off a file by path without buffering it into memory, and pass `null` from the Send flow instead of a throwaway empty buffer. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -386,7 +386,7 @@ export class NodeAppService extends BaseAppService {
|
||||
|
||||
async saveFile(
|
||||
_filename: string,
|
||||
content: string | ArrayBuffer,
|
||||
content: string | ArrayBuffer | null,
|
||||
options?: {
|
||||
filePath?: string;
|
||||
mimeType?: string;
|
||||
@@ -399,7 +399,7 @@ export class NodeAppService extends BaseAppService {
|
||||
await fsp.mkdir(nodePath.dirname(filepath), { recursive: true });
|
||||
if (typeof content === 'string') {
|
||||
await fsp.writeFile(filepath, content, 'utf-8');
|
||||
} else {
|
||||
} else if (content) {
|
||||
await fsp.writeFile(filepath, Buffer.from(content));
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user