db/Song: translate relative "real_uri" paths
This commit is contained in:
parent
9caf90f74f
commit
91c1274ac6
@ -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
|
|||||||
DetachedSong detached(song);
|
DetachedSong detached(song);
|
||||||
assert(detached.IsInDatabase());
|
assert(detached.IsInDatabase());
|
||||||
|
|
||||||
if (!detached.HasRealURI() && storage != nullptr) {
|
if (storage != nullptr) {
|
||||||
const auto uri = song.GetURI();
|
if (!detached.HasRealURI()) {
|
||||||
detached.SetRealURI(storage->MapUTF8(uri.c_str()));
|
const auto uri = song.GetURI();
|
||||||
|
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;
|
||||||
|
Loading…
Reference in New Issue
Block a user