Fix SS export when image names (without extension) conflict (BL-16498)#8042
Fix SS export when image names (without extension) conflict (BL-16498)#8042StephenMcConnel wants to merge 3 commits into
Conversation
The initial fix renamed a colliding image to `{name}-{rowNum}` but appended
the suffix blindly without re-checking, and compared case-insensitively while
renaming with the original casing. So the renamed value could still collide
(e.g. three images sharing a base name in one row, or two same-row names
differing only in case), causing AddPicture to throw the very EPPlus
name-collision exception BL-16498 set out to prevent. Loop until the name is
truly unique (case-insensitively), matching EPPlus semantics.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
| Filename | Overview |
|---|---|
| src/BloomExe/Spreadsheet/SpreadsheetIO.cs | Replaces a case-sensitive, single-attempt duplicate-name check with a case-insensitive do...while loop that keeps incrementing the suffix until the drawing name is genuinely unique, matching EPPlus's own case-insensitive uniqueness requirement. |
| src/BloomTests/Spreadsheet/SpreadsheetImagesTests.cs | Adds a regression test that exports a book with three images whose base names collide both exactly and case-insensitively, then verifies all three embed without error and no warnings are raised. |
Reviews (2): Last reviewed commit: "Add regression test for SS export image-..." | Re-trigger Greptile
|
[Claude Opus 4.8 (1M context)] Consulted Devin on 2026-07-07 20:13 UTC up to commit |
Exports a small book whose three image files reduce to the same EPPlus drawing name once the extension is dropped — including names that differ only in case (conflict.png / Conflict.jpg / conflict.gif) — and asserts every image embeds with no error message and no warning. Verified the test fails against the pre-fix code (the case-differing image was reported as a "Bad image file" because EPPlus rejected the duplicate drawing name) and passes with the fix. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
[Claude Opus 4.8 (1M context)] Consulted Devin on 2026-07-07 20:54 UTC up to commit |
Fixes the error thrown during Spreadsheet (SS) export when a book contains image files whose names, stripped of extension, collide.
Problem
EPPlus treats worksheet drawing names as case-insensitive and rejects duplicates. Two source files such as
image.jpgandimage.png(orFoo.pngandfoo.jpg) reduce to the same drawing name, soworksheet.Drawings.AddPicture(...)threw during export.Fix
d34355b92— make the duplicate-name check case-insensitive and rename a colliding image to{name}-{rowNum}.74e34419d— guarantee the renamed value is actually unique. The first commit appended the-{rowNum}suffix blindly (no re-check) and renamed using the original casing, so the result could still collide (e.g. three images sharing a base name in one row, or two same-row names differing only in case). Now we loop, comparing case-insensitively, until the name is truly unique — matching EPPlus semantics.Testing
BloomExeandBloomTestsbuild cleanly.Ref: https://issues.bloomlibrary.org/issue/BL-16498
Devin review
This change is