From f0f5300891408d9487f72d56e91de46c62eacb7b Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Wed, 29 May 2024 00:18:39 +0200 Subject: [PATCH] ParserBase: Make the path absolute and try canonical path Somehow I got this mixed up in commit 2953f9e :( Fixes #1448 --- src/playlistparsers/parserbase.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/playlistparsers/parserbase.cpp b/src/playlistparsers/parserbase.cpp index 3a97ce484..7f84f1c59 100644 --- a/src/playlistparsers/parserbase.cpp +++ b/src/playlistparsers/parserbase.cpp @@ -64,6 +64,12 @@ void ParserBase::LoadSong(const QString &filename_or_url, const qint64 beginning } filename = QDir::cleanPath(filename); + + // Make the path absolute + if (!QDir::isAbsolutePath(filename)) { + filename = dir.absoluteFilePath(filename); + } + const QUrl url = QUrl::fromLocalFile(filename); // Search the collection @@ -75,16 +81,16 @@ void ParserBase::LoadSong(const QString &filename_or_url, const qint64 beginning if (!collection_song.is_valid()) { collection_song = collection_backend_->GetSongByUrl(url, beginning); } - // Try absolute path - if (!collection_song.is_valid() && !QDir::isAbsolutePath(filename)) { - QString absolute_filename = dir.absoluteFilePath(filename); - if (absolute_filename != filename) { - const QUrl absolute_url = QUrl::fromLocalFile(absolute_filename); + // Try canonical path + if (!collection_song.is_valid()) { + const QString canonical_filepath = QFileInfo(filename).canonicalFilePath(); + if (canonical_filepath != filename) { + const QUrl canonical_filepath_url = QUrl::fromLocalFile(canonical_filepath); if (track > 0) { - collection_song = collection_backend_->GetSongByUrlAndTrack(absolute_url, track); + collection_song = collection_backend_->GetSongByUrlAndTrack(canonical_filepath_url, track); } if (!collection_song.is_valid()) { - collection_song = collection_backend_->GetSongByUrl(absolute_url, beginning); + collection_song = collection_backend_->GetSongByUrl(canonical_filepath_url, beginning); } } }