Skip to content

WeBWorK: overwrite prior image files when unpacking an archive - #3078

Merged
rbeezer merged 1 commit into
PreTeXtBook:masterfrom
rbeezer:webwork-image-replace
Jul 28, 2026
Merged

WeBWorK: overwrite prior image files when unpacking an archive#3078
rbeezer merged 1 commit into
PreTeXtBook:masterfrom
rbeezer:webwork-image-replace

Conversation

@rbeezer

@rbeezer rbeezer commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Regenerating WeBWorK representations on Windows fails to update TikZ images, reported on pretext-support: each downloaded .tgz image archive extracts correctly, but the subsequent os.rename of image.tex/image.pdf/image.svg/image.png to the problem's image name raises FileExistsError on Windows whenever a prior run's file is present (POSIX replaces silently). The bare except then reports the failure as "did not contain a ... file" — for every problem and every format — and the archive is discarded, leaving stale images. os.replace() has the same signature and silently overwrites the destination on all platforms, so a Linux run is unchanged and a Windows run now overwrites prior generated images, matching Linux. In passing, the warning-message template moves adjacent to its single use.

Verified on Linux with the WeBWorK sample chapter against webwork-ptx.aimath.org: before/after runs produce identical image inventories, byte-identical representation files and .tex/.svg images, and pixel-identical .pdf/.png images (byte differences are per-request server rendering); regenerating into an already-populated images directory completes with no warnings.

Claude Fable 5, acting as a coding assistant for Rob Beezer

@rbeezer

rbeezer commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator Author

Looking for confirmation on a Windows machine....

@rbeezer

rbeezer commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator Author

For @sean-fitzpatrick

@sean-fitzpatrick

Copy link
Copy Markdown
Contributor

I applied the change manually on my Windows computer, and got a clean run, with all the images where they're supposed to be. This seems to resolve the issue!

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@rbeezer
rbeezer force-pushed the webwork-image-replace branch from 25f8eb2 to 5288bf9 Compare July 28, 2026 02:46
@rbeezer
rbeezer merged commit 6e1d4c3 into PreTeXtBook:master Jul 28, 2026
@rbeezer
rbeezer deleted the webwork-image-replace branch July 28, 2026 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants