Expected behaviour
When an attached file has no extension, or one that does not match its type, the saved copy should use the suffix QOwnNotes detected from the mime type.
Actual behaviour
That detected suffix is discarded, so the saved file keeps the suffix of the input path, or none at all.
Utils::Misc::findAvailableFileName() takes an overrideSuffix parameter (src/utils/misc.h:151) that its body never reads (src/utils/misc.cpp:2742):
const QString newSuffix = fileInfo.suffix(); // overrideSuffix unused
Both callers in src/entities/note.cpp pass a mime-detected suffix, at lines 6201 and 6300. The sibling makeFileNameRandom() has the same parameter and honours it.
Steps to reproduce
- Take a PNG file with its extension removed, named
screenshot.
- Insert it with Insert attachment.
- It lands in the attachments folder still named
screenshot, so it no longer opens in an image viewer on double click.
A JPEG named screenshot.jpeg is detected as jpg but keeps .jpeg.
Driving the real function with the same mime detection the callers use:
input 'screenshot' mime=image/png detected suffix='png'
current : screenshot
expected: screenshot.png
input 'screenshot.jpeg' mime=image/jpeg detected suffix='jpg'
current : screenshot.jpeg
expected: screenshot.jpg
Screenshots
Not applicable, this is a file naming issue.
Output from the debug section in the settings dialog
Expand
Not run from an installed instance. Found by reading the code, reproduced by building the unit test target from main against Qt 5.15.2 on Linux.
Relevant log output in the Log panel
Expand
Nothing is logged for this.
PR #3700 fixes this and adds a unit test.
Written with AI assistance (Claude Code). I built and ran the test target and produced the output above myself.
Expected behaviour
When an attached file has no extension, or one that does not match its type, the saved copy should use the suffix QOwnNotes detected from the mime type.
Actual behaviour
That detected suffix is discarded, so the saved file keeps the suffix of the input path, or none at all.
Utils::Misc::findAvailableFileName()takes anoverrideSuffixparameter (src/utils/misc.h:151) that its body never reads (src/utils/misc.cpp:2742):Both callers in
src/entities/note.cpppass a mime-detected suffix, at lines 6201 and 6300. The siblingmakeFileNameRandom()has the same parameter and honours it.Steps to reproduce
screenshot.screenshot, so it no longer opens in an image viewer on double click.A JPEG named
screenshot.jpegis detected asjpgbut keeps.jpeg.Driving the real function with the same mime detection the callers use:
Screenshots
Not applicable, this is a file naming issue.
Output from the debug section in the settings dialog
Expand
Not run from an installed instance. Found by reading the code, reproduced by building the unit test target from
mainagainst Qt 5.15.2 on Linux.Relevant log output in the Log panel
Expand
Nothing is logged for this.
PR #3700 fixes this and adds a unit test.
Written with AI assistance (Claude Code). I built and ran the test target and produced the output above myself.