Skip to content

fix(RenameFile): fix doubled file extension causing 'File name too long' error - #768

Open
garfolino wants to merge 3 commits into
stashapp:mainfrom
garfolino:renamefile-fix-long-filename-macos
Open

fix(RenameFile): fix doubled file extension causing 'File name too long' error#768
garfolino wants to merge 3 commits into
stashapp:mainfrom
garfolino:renamefile-fix-long-filename-macos

Conversation

@garfolino

@garfolino garfolino commented Aug 29, 2026

Copy link
Copy Markdown

Fixes #767

Depends on #733 — this branch is built on top of fix/renamefile-title-stuck (which bumps RenameFile to 1.0.1), so this PR's diff includes that PR's commit and bumps the version again to 1.0.2 on top of it. GitHub doesn't allow targeting a base branch that only exists in a fork, so this still shows as based on main; please merge/land #733 first, or review this diff as the two commits after 785fa73.

Summary

  • Fix the long-filename truncation fallback in RenameFile so it no longer doubles the file extension and correctly reserves space for the hash suffix, which was causing OSError: [Errno 63] File name too long (macOS) / ENAMETOOLONG when renaming scenes whose formatted filename exceeded max_filename_length.
  • When a rename/move does fail, stop the OSError from being re-raised into the top-level catch-all (which dumped a full Python traceback into the log on top of the already-logged clear error message).
  • Bump plugin version to 1.0.2 (on top of fix(RenameFile): prevent scene title freezing on Next navigation #733's 1.0.1) and update the changelog.

Root cause

See #767 for the full analysis. In short: the truncation branch built new_filename as truncated + '_' + hash + extension, but the length budget it truncated to only subtracted the extension length (not the _+hash), and the caller then appended the extension a second time (newFilenameWithExt = new_filename + suffix), producing filenames like ....mp4.mp4 well past max_filename_length.

Testing

  • Reproduced the exact reported failure by hand: recomputed the original 292-character doubled-extension filename from the logged error and confirmed the new logic instead produces a name at or under the configured max_filename_length, with a single extension.
  • Ran the repo's plugin validator (node ./validator/index.js --ci) — passes.
  • Not yet exercised against a live Stash instance with an actual over-long title/tag combination; recommend a maintainer or the reporter re-test the original scenario before merge.

AI disclosure

This fix (analysis, code changes, issue text, and this PR description) was drafted with LLM (Claude) assistance from a real user-reported error log. The diff was reviewed by a human before submission, per the repo's LLM-assisted contribution policy.

garfolino and others added 3 commits June 27, 2026 15:48
The scene title is rendered by a React-controlled TruncatedText component.
The plugin replaced its contents with an <a> element (innerHTML = ''),
which detached the text node React updates. Navigating to another scene
with Next then left the previous title displayed while every other field
updated.

Switch to event delegation: a single document-level click listener reads
the title at click time, so React's DOM is never restructured. The styling
class and tooltip are now applied non-destructively (attributes only).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ng filename truncation

The truncation branch appended the file extension before computing/adding
the hash suffix, so the length budget didn't account for the "_"+hash
appended afterward, and the extension got appended a second time later,
producing filenames like "....mp4.mp4" that exceeded the OS filename
limit and caused OSError: File name too long.
… the log

When rename/move failed with an OSError, stash.Error(exitMsg) already
logs a clear one-line message, but the code then re-raised the
exception, which propagated to the top-level catch-all and dumped the
full Python traceback to stderr as a second, noisy Error entry (this is
what showed up in the "file name too long" report). Return None instead
so only the clear message is surfaced.
@garfolino
garfolino force-pushed the renamefile-fix-long-filename-macos branch from d950ea0 to a9d3423 Compare August 29, 2026 21:12
@DogmaDragon DogmaDragon added the type:plugin Plugins label Aug 29, 2026
@discourse-stashapp

Copy link
Copy Markdown

This pull request has been mentioned on Stash Forum. There might be relevant details there:

https://discourse.stashapp.cc/t/renamefile/1334/9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RenameFile: OSError 'File name too long' from doubled extension in long-filename truncation

3 participants