Commit bcf46452 authored by Max Kellermann's avatar Max Kellermann

db/simple/Directory: add LookupResult::uri

parent 6c8eb3c7
...@@ -133,7 +133,7 @@ Directory::LookupDirectory(const char *_uri) noexcept ...@@ -133,7 +133,7 @@ Directory::LookupDirectory(const char *_uri) noexcept
assert(_uri != nullptr); assert(_uri != nullptr);
if (isRootDirectory(_uri)) if (isRootDirectory(_uri))
return { this, nullptr }; return { this, _uri, nullptr };
StringView uri(_uri); StringView uri(_uri);
...@@ -156,7 +156,7 @@ Directory::LookupDirectory(const char *_uri) noexcept ...@@ -156,7 +156,7 @@ Directory::LookupDirectory(const char *_uri) noexcept
uri = rest; uri = rest;
} while (uri != nullptr); } while (uri != nullptr);
return { d, uri.data }; return { d, StringView(_uri, uri.data - 1), uri.data };
} }
void void
......
...@@ -183,6 +183,11 @@ public: ...@@ -183,6 +183,11 @@ public:
Directory *directory; Directory *directory;
/** /**
* The URI part which resolved to the #directory.
*/
std::string_view uri;
/**
* The remaining URI part (without leading slash) or * The remaining URI part (without leading slash) or
* nullptr if the given URI was consumed completely. * nullptr if the given URI was consumed completely.
*/ */
......
...@@ -217,7 +217,7 @@ SimpleDatabase::GetSong(const char *uri) const ...@@ -217,7 +217,7 @@ SimpleDatabase::GetSong(const char *uri) const
return nullptr; return nullptr;
prefixed_light_song = prefixed_light_song =
new PrefixedLightSong(*song, r.directory->GetPath()); new PrefixedLightSong(*song, r.uri);
r.directory->mounted_database->ReturnSong(song); r.directory->mounted_database->ReturnSong(song);
return prefixed_light_song; return prefixed_light_song;
} }
...@@ -289,7 +289,7 @@ SimpleDatabase::Visit(const DatabaseSelection &selection, ...@@ -289,7 +289,7 @@ SimpleDatabase::Visit(const DatabaseSelection &selection,
/* pass the request and the remaining uri to the mounted database */ /* pass the request and the remaining uri to the mounted database */
protect.unlock(); protect.unlock();
WalkMount(r.directory->GetPath(), *(r.directory->mounted_database), WalkMount(r.uri, *(r.directory->mounted_database),
(r.rest == nullptr)?"":r.rest, selection, (r.rest == nullptr)?"":r.rest, selection,
visit_directory, visit_song, visit_playlist); visit_directory, visit_song, visit_playlist);
......
...@@ -196,11 +196,7 @@ UpdateService::Enqueue(const char *path, bool discard) ...@@ -196,11 +196,7 @@ UpdateService::Enqueue(const char *path, bool discard)
storage2 = storage.GetMount(path); storage2 = storage.GetMount(path);
path = ""; path = "";
} else { } else {
assert(lr.rest > path); const std::string mountpoint(lr.uri);
assert(lr.rest < path + strlen(path));
assert(lr.rest[-1] == '/');
const std::string mountpoint(path, lr.rest - 1);
storage2 = storage.GetMount(mountpoint.c_str()); storage2 = storage.GetMount(mountpoint.c_str());
path = lr.rest; path = lr.rest;
} }
......
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