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:
Huang Xin
2026-06-02 22:49:47 +08:00
committed by GitHub
parent df66c63a07
commit e4bb9fc4b7
7 changed files with 40 additions and 14 deletions
@@ -517,10 +517,9 @@ const Bookshelf: React.FC<BookshelfProps> = ({
// whole epub/pdf into memory just to have saveFile write it back
// to disk.
const absoluteFilePath = await appService.resolveFilePath(path, base);
// saveFile's binary branch wants an ArrayBuffer; with `filePath`
// set the content arg is ignored on the native share path, but
// we still pass an empty buffer so the type-checker is happy.
await appService.saveFile(shareFilename, new ArrayBuffer(0), {
// `null` content: there's nothing to write — the file already lives at
// `filePath`, which the native share path reads directly.
await appService.saveFile(shareFilename, null, {
share: true,
mimeType,
filePath: absoluteFilePath,