Skip to content

Fix incorrect sequence number placement - #4716

Open
xkello wants to merge 1 commit into
masterfrom
bugfix/fix-sequence-number-positioning
Open

xkello wants to merge 1 commit into
masterfrom
bugfix/fix-sequence-number-positioning

Conversation

@xkello

@xkello xkello commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Description

Photo renaming broke for any file with more than one dot in its name. When a rename collided with an existing file, the app inserted the "(1)" counter in the wrong spot instead of right before the file extension.

Fixes: #4135

What changed

CoreUtils::findUniquePath() and AttributeController::renamePhotos() used to split filenames on the first dot to separate name from extension. Both now split on the last dot instead, so only the real extension gets treated as the extension. Added tests for names with multiple dots.

Behaviour

  • Before: site.alpha.beta.jpg > site (1).alpha.beta.jpg
  • After: site.alpha.beta.jpg > site.alpha.beta (1).jpg
  • This also fixes photo names getting part of the old filename duplicated onto the new one during renaming.

@xkello
xkello requested a review from Withalion September 24, 2026 14:43

@Withalion Withalion left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments below, tests will need some work

Comment thread core/coreutils.cpp
{
uniquePath = originalPath.path() + '/' + originalPath.baseName() + " (" + QString::number( i ) + ")." + originalPath.completeSuffix();
// split on the last dot, so a dot in the base name isn't mistaken for the extension
uniquePath = originalPath.path() + '/' + originalPath.completeBaseName() + " (" + QString::number( i ) + ")." + originalPath.suffix();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would replace this with: QStringLiteral("%1/%2 (%3).%4").arg(...)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice, but it would be better to improve TestCoreUtils::testFindUniquePath

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.

Photo naming: Sequence number inserted at wrong position when filename contains multiple dots

2 participants