Skip to content

Commit cb46d61

Browse files
committed
Overlay branch overlay/web-picked-image-copy on top of origin/main via Merge
• e0af0887c2 Overlay branch overlay/web-picked-image-copy on top of origin/main via Merge |\ | • 2fc4130 Overlay branch overlay/web-picked-image-copy on top of origin/main via Merge | |\ | | • bc32d70 fix(web): cropped screenshots upload from Android Chrome • | | 7873f53 fix(web): the Add ChatGPT account dialog animates closed once the account connects (pingdotgg#25868) • | | 1152e91 fix(desktop): run the packaged bundle self-check on macOS artifacts (pingdotgg#25900) • | | 58c31f2 refactor(mobile): settings permission and update checks without sync effects (pingdotgg#25895) • | | 79f6cd3 refactor(mobile): workspace tabs, home filters and connection status derive instead of syncing (pingdotgg#25813) • | | 790ba13 refactor(mobile): app update checks start with the app (pingdotgg#25856)
2 parents 7873f53 + 2fc4130 commit cb46d61

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)