Commit 91c1274a authored by Max Kellermann's avatar Max Kellermann

db/Song: translate relative "real_uri" paths

parent 9caf90f7
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#include "song/LightSong.hxx" #include "song/LightSong.hxx"
#include "storage/StorageInterface.hxx" #include "storage/StorageInterface.hxx"
#include "util/ScopeExit.hxx" #include "util/ScopeExit.hxx"
#include "util/UriExtract.hxx"
#include "util/UriRelative.hxx"
#include <assert.h> #include <assert.h>
...@@ -32,9 +34,19 @@ DatabaseDetachSong(const Storage *storage, const LightSong &song) noexcept ...@@ -32,9 +34,19 @@ DatabaseDetachSong(const Storage *storage, const LightSong &song) noexcept
DetachedSong detached(song); DetachedSong detached(song);
assert(detached.IsInDatabase()); assert(detached.IsInDatabase());
if (!detached.HasRealURI() && storage != nullptr) { if (storage != nullptr) {
if (!detached.HasRealURI()) {
const auto uri = song.GetURI(); const auto uri = song.GetURI();
detached.SetRealURI(storage->MapUTF8(uri.c_str())); detached.SetRealURI(storage->MapUTF8(uri.c_str()));
} else if (uri_is_relative_path(detached.GetRealURI())) {
/* if the "RealURI" is relative, translate it
using the song's "URI" attribute, because
it's assumed to be relative to it */
const auto real_uri =
uri_apply_relative(detached.GetRealURI(),
song.GetURI());
detached.SetRealURI(storage->MapUTF8(real_uri.c_str()));
}
} }
return detached; return detached;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment