db/update/Playlist: prepend "../" only for relative URIs

Prepending "../" to absolute URIs would break them.
This commit is contained in:
Max Kellermann 2021-08-05 20:10:51 +02:00
parent 1761fb14af
commit 8e0d39ae94
2 changed files with 10 additions and 1 deletions

1
NEWS
View File

@ -3,6 +3,7 @@ ver 0.22.10 (not yet released)
- support "albumart" for virtual tracks in CUE sheets - support "albumart" for virtual tracks in CUE sheets
* database * database
- simple: fix crash bug - simple: fix crash bug
- simple: fix absolute paths in CUE "as_directory" entries
* input * input
- curl: fix crash bug after stream with Icy metadata was closed by peer - curl: fix crash bug after stream with Icy metadata was closed by peer
- tidal: remove defunct unmaintained plugin - tidal: remove defunct unmaintained plugin

View File

@ -30,6 +30,7 @@
#include "playlist/SongEnumerator.hxx" #include "playlist/SongEnumerator.hxx"
#include "storage/FileInfo.hxx" #include "storage/FileInfo.hxx"
#include "storage/StorageInterface.hxx" #include "storage/StorageInterface.hxx"
#include "fs/Traits.hxx"
#include "util/StringFormat.hxx" #include "util/StringFormat.hxx"
#include "Log.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), auto db_song = std::make_unique<Song>(std::move(*song),
*directory); *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", db_song->filename = StringFormat<64>("track%04u",
++track); ++track);