| Summary: | kid3-cli can't open file starting with colon | ||
|---|---|---|---|
| Product: | [Applications] kid3 | Reporter: | Mike Jonkmans <kde> |
| Component: | general | Assignee: | Urs Fleisch <ufleisch> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | NOR | ||
| Version First Reported In: | 3.9.x | ||
| Target Milestone: | --- | ||
| Platform: | Ubuntu | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
Mike Jonkmans
2023-01-02 20:22:01 UTC
Thanks for the report. I analyzed the case using gdb and found out that the problem starts when QFileInfo is used:
kid3application.cpp:
839 for (const QString& path : pathList) {
840 if (!path.isEmpty()) {
841 QFileInfo fileInfo(path);
842 if (fileCheck && !fileInfo.exists()) {
fileInfo.exists() will return false if path starts with a colon. See https://doc.qt.io/qt-6/qfileinfo.html for the explanation:
> Note: Paths starting with a colon (:) are always considered absolute, as they denote a QResource.
You can use the following workaround: Use "./:a.mp4" instead of ":a.mp4" (or use the absolute path to the file).
(In reply to Urs Fleisch from comment #1) > Thanks for the report. Thanks for the swift response and the great software :) > I analyzed the case using gdb and found out that the > problem starts when QFileInfo is used: > > kid3application.cpp: > 839 for (const QString& path : pathList) { > 840 if (!path.isEmpty()) { > 841 QFileInfo fileInfo(path); > 842 if (fileCheck && !fileInfo.exists()) { > > fileInfo.exists() will return false if path starts with a colon. See > https://doc.qt.io/qt-6/qfileinfo.html for the explanation: > > > Note: Paths starting with a colon (:) are always considered absolute, as they denote a QResource. I see, reading further, the exact 'problem' is described here: https://doc.qt.io/qt-6/resources.html#runtime-api It would have been nice if somehow the QFileInfo.exists() method could be told to skip the resource indicators. For instance via a flag to the exists method or via the QFileInfo constructor. But that is out of scope here. > You can use the following workaround: Use "./:a.mp4" instead of ":a.mp4" (or > use the absolute path to the file). This is a nice workaround. Better than what I did (link the file to a fixed name). -- Regards, Mike I have now implemented a fix to check for files starting with a colon and automatically prepending "./", you can find a development snapshot git20230103 at https://sourceforge.net/projects/kid3/files/kid3/development/. The snapshot works. Nice fix! I found another case though: 1. touch :a.mp4 2. kid3-cli -c 'select :a.mp4' Looks like the same problem. The workaround of manually putting './' in front also works here. Thanks for the information. I have now fixed the case for select in kid3-git20230104. I checked it. It works. Thanks! Fixed in version 3.9.3. |