From bcf4645263a9d4f0b188a6506db8b5650b1df0b1 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 3 Apr 2020 17:08:24 +0200 Subject: [PATCH] db/simple/Directory: add LookupResult::uri --- src/db/plugins/simple/Directory.cxx | 4 ++-- src/db/plugins/simple/Directory.hxx | 5 +++++ src/db/plugins/simple/SimpleDatabasePlugin.cxx | 4 ++-- src/db/update/Service.cxx | 6 +----- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/db/plugins/simple/Directory.cxx b/src/db/plugins/simple/Directory.cxx index 4c4522622..0b821fac4 100644 --- a/src/db/plugins/simple/Directory.cxx +++ b/src/db/plugins/simple/Directory.cxx @@ -133,7 +133,7 @@ Directory::LookupDirectory(const char *_uri) noexcept assert(_uri != nullptr); if (isRootDirectory(_uri)) - return { this, nullptr }; + return { this, _uri, nullptr }; StringView uri(_uri); @@ -156,7 +156,7 @@ Directory::LookupDirectory(const char *_uri) noexcept uri = rest; } while (uri != nullptr); - return { d, uri.data }; + return { d, StringView(_uri, uri.data - 1), uri.data }; } void diff --git a/src/db/plugins/simple/Directory.hxx b/src/db/plugins/simple/Directory.hxx index cc3003fc2..49df25ee2 100644 --- a/src/db/plugins/simple/Directory.hxx +++ b/src/db/plugins/simple/Directory.hxx @@ -182,6 +182,11 @@ public: */ Directory *directory; + /** + * The URI part which resolved to the #directory. + */ + std::string_view uri; + /** * The remaining URI part (without leading slash) or * nullptr if the given URI was consumed completely. diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.cxx b/src/db/plugins/simple/SimpleDatabasePlugin.cxx index 9df3ca066..f2a420fec 100644 --- a/src/db/plugins/simple/SimpleDatabasePlugin.cxx +++ b/src/db/plugins/simple/SimpleDatabasePlugin.cxx @@ -217,7 +217,7 @@ SimpleDatabase::GetSong(const char *uri) const return nullptr; prefixed_light_song = - new PrefixedLightSong(*song, r.directory->GetPath()); + new PrefixedLightSong(*song, r.uri); r.directory->mounted_database->ReturnSong(song); return prefixed_light_song; } @@ -289,7 +289,7 @@ SimpleDatabase::Visit(const DatabaseSelection &selection, /* pass the request and the remaining uri to the mounted database */ protect.unlock(); - WalkMount(r.directory->GetPath(), *(r.directory->mounted_database), + WalkMount(r.uri, *(r.directory->mounted_database), (r.rest == nullptr)?"":r.rest, selection, visit_directory, visit_song, visit_playlist); diff --git a/src/db/update/Service.cxx b/src/db/update/Service.cxx index d885381e4..dc09d79ad 100644 --- a/src/db/update/Service.cxx +++ b/src/db/update/Service.cxx @@ -196,11 +196,7 @@ UpdateService::Enqueue(const char *path, bool discard) storage2 = storage.GetMount(path); path = ""; } else { - assert(lr.rest > path); - assert(lr.rest < path + strlen(path)); - assert(lr.rest[-1] == '/'); - - const std::string mountpoint(path, lr.rest - 1); + const std::string mountpoint(lr.uri); storage2 = storage.GetMount(mountpoint.c_str()); path = lr.rest; }