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
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
......
......@@ -183,6 +183,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.
*/
......
......@@ -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);
......
......@@ -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;
}
......
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