summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2021-08-05 20:10:51 +0200
committerMax Kellermann <max@musicpd.org>2021-08-05 20:19:33 +0200
commit8e0d39ae944263339773c6804846751701092fc6 (patch)
tree676cd7d269792ade737ec99c6e7959bda6d64a16
parent1761fb14af6c810735fa456cd19274681a89a1c9 (diff)
db/update/Playlist: prepend "../" only for relative URIs
Prepending "../" to absolute URIs would break them.
-rw-r--r--NEWS1
-rw-r--r--src/db/update/Playlist.cxx10
2 files changed, 10 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index ab2ddd9ca..28a9acb36 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ ver 0.22.10 (not yet released)
- support "albumart" for virtual tracks in CUE sheets
* database
- simple: fix crash bug
+ - simple: fix absolute paths in CUE "as_directory" entries
* input
- curl: fix crash bug after stream with Icy metadata was closed by peer
- tidal: remove defunct unmaintained plugin
diff --git a/src/db/update/Playlist.cxx b/src/db/update/Playlist.cxx
index e3ad54ae0..927818ee0 100644
--- a/src/db/update/Playlist.cxx
+++ b/src/db/update/Playlist.cxx
@@ -30,6 +30,7 @@
#include "playlist/SongEnumerator.hxx"
#include "storage/FileInfo.hxx"
#include "storage/StorageInterface.hxx"
+#include "fs/Traits.hxx"
#include "util/StringFormat.hxx"
#include "Log.hxx"
@@ -70,7 +71,14 @@ UpdateWalk::UpdatePlaylistFile(Directory &parent, std::string_view name,
auto db_song = std::make_unique<Song>(std::move(*song),
*directory);
- db_song->target = "../" + db_song->filename;
+ db_song->target =
+ PathTraitsUTF8::IsAbsoluteOrHasScheme(db_song->filename.c_str())
+ ? db_song->filename
+ /* prepend "../" to relative paths to
+ go from the virtual directory
+ (DEVICE_PLAYLIST) to the containing
+ directory */
+ : "../" + db_song->filename;
db_song->filename = StringFormat<64>("track%04u",
++track);