Skip to content

Commit 2fc4130

Browse files
committed
Overlay branch overlay/web-picked-image-copy on top of origin/main via Merge
* apps/web/src/lib/imageCompression.ts • 74858edf02 Overlay branch overlay/web-picked-image-copy on top of origin/main via Merge |\ | • bc32d70 fix(web): cropped screenshots upload from Android Chrome • | becf853 fix(web): PDF search finds phrases that wrap across lines (pingdotgg#25702) • | 68339a0 refactor(mobile): pull request list, filters and viewed files without synchronizing effects (pingdotgg#25614) • | a2398c2 refactor(mobile): thread inspector mode is derived, not synced (pingdotgg#25682) • | 9bc0c33 refactor(mobile): settings use web's pages and groups (pingdotgg#25686) • | 5432d8e refactor(web): drafts promote from the draft store, not from route effects (pingdotgg#25615) • | bd3287b feat(web): thread state lives at the end of the timeline, not stacked on the composer (pingdotgg#25401)
2 parents becf853 + bc32d70 commit 2fc4130

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

‎apps/web/src/lib/imageCompression.test.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,16 @@ describe("attachment max edge", () => {
432432

433433
const result = await prepareImageForAttachment(original, 10 * 1024 * 1024);
434434

435-
expect(result.ok && result.file).toBe(original);
436435
expect(result.ok && result.recompressed).toBe(false);
437436
expect(decode).not.toHaveBeenCalled();
437+
if (!result.ok) return;
438+
// Uploading the picked File itself fails on Android Chrome for some sources.
439+
expect(result.file).not.toBe(original);
440+
expect(result.file.name).toBe(original.name);
441+
expect(result.file.type).toBe(original.type);
442+
expect(new Uint8Array(await result.file.arrayBuffer())).toEqual(
443+
new Uint8Array(await original.arrayBuffer()),
444+
);
438445
});
439446
});
440447

‎apps/web/src/lib/imageCompression.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,18 @@ export async function prepareImageForAttachment(
459459
maxBytes: number,
460460
): Promise<CompressImageFileResult> {
461461
if (!isHeicImageFile(file)) {
462-
return compressImageToByteLimit(file, maxBytes);
462+
const result = await compressImageToByteLimit(file, maxBytes);
463+
// Android Chrome re-checks a picked file's source when uploading it, and some sources
464+
// (Samsung's cropped screenshots, Drive) report a new modification time, so the upload
465+
// fails with ERR_UPLOAD_FILE_CHANGED (crbug.com/40123366). A copy in memory has no source.
466+
if (!result.ok || result.file !== file) return result;
467+
return {
468+
...result,
469+
file: new File([await file.arrayBuffer()], file.name, {
470+
type: file.type,
471+
lastModified: file.lastModified,
472+
}),
473+
};
463474
}
464475

465476
if (file.size > MAX_COMPRESSIBLE_SOURCE_BYTES) {

0 commit comments

Comments
 (0)