From 6c8eb3c7ed89d0d174ca2fceaf8bfdc4dcd513b6 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 3 Apr 2020 17:06:25 +0200 Subject: [PATCH] db/simple/Directory: rename LookupResult::uri to "rest" --- src/db/plugins/simple/Directory.hxx | 2 +- .../plugins/simple/SimpleDatabasePlugin.cxx | 24 +++++++++---------- src/db/update/Service.cxx | 12 +++++----- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/db/plugins/simple/Directory.hxx b/src/db/plugins/simple/Directory.hxx index a3533807a..cc3003fc2 100644 --- a/src/db/plugins/simple/Directory.hxx +++ b/src/db/plugins/simple/Directory.hxx @@ -186,7 +186,7 @@ public: * The remaining URI part (without leading slash) or * nullptr if the given URI was consumed completely. */ - const char *uri; + const char *rest; }; /** diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.cxx b/src/db/plugins/simple/SimpleDatabasePlugin.cxx index d0bae6c0c..9df3ca066 100644 --- a/src/db/plugins/simple/SimpleDatabasePlugin.cxx +++ b/src/db/plugins/simple/SimpleDatabasePlugin.cxx @@ -212,7 +212,7 @@ SimpleDatabase::GetSong(const char *uri) const protect.unlock(); const LightSong *song = - r.directory->mounted_database->GetSong(r.uri); + r.directory->mounted_database->GetSong(r.rest); if (song == nullptr) return nullptr; @@ -222,17 +222,17 @@ SimpleDatabase::GetSong(const char *uri) const return prefixed_light_song; } - if (r.uri == nullptr) + if (r.rest == nullptr) /* it's a directory */ throw DatabaseError(DatabaseErrorCode::NOT_FOUND, "No such song"); - if (strchr(r.uri, '/') != nullptr) + if (strchr(r.rest, '/') != nullptr) /* refers to a URI "below" the actual song */ throw DatabaseError(DatabaseErrorCode::NOT_FOUND, "No such song"); - const Song *song = r.directory->FindSong(r.uri); + const Song *song = r.directory->FindSong(r.rest); protect.unlock(); if (song == nullptr) throw DatabaseError(DatabaseErrorCode::NOT_FOUND, @@ -290,7 +290,7 @@ SimpleDatabase::Visit(const DatabaseSelection &selection, protect.unlock(); WalkMount(r.directory->GetPath(), *(r.directory->mounted_database), - (r.uri == nullptr)?"":r.uri, selection, + (r.rest == nullptr)?"":r.rest, selection, visit_directory, visit_song, visit_playlist); return; @@ -298,7 +298,7 @@ SimpleDatabase::Visit(const DatabaseSelection &selection, DatabaseVisitorHelper helper(CheckSelection(selection), visit_song); - if (r.uri == nullptr) { + if (r.rest == nullptr) { /* it's a directory */ if (selection.recursive && visit_directory) @@ -311,9 +311,9 @@ SimpleDatabase::Visit(const DatabaseSelection &selection, return; } - if (strchr(r.uri, '/') == nullptr) { + if (strchr(r.rest, '/') == nullptr) { if (visit_song) { - Song *song = r.directory->FindSong(r.uri); + Song *song = r.directory->FindSong(r.rest); if (song != nullptr) { const LightSong song2 = song->Export(); if (selection.Match(song2)) @@ -402,15 +402,15 @@ SimpleDatabase::Mount(const char *uri, DatabasePtr db) ScopeDatabaseLock protect; auto r = root->LookupDirectory(uri); - if (r.uri == nullptr) + if (r.rest == nullptr) throw DatabaseError(DatabaseErrorCode::CONFLICT, "Already exists"); - if (strchr(r.uri, '/') != nullptr) + if (strchr(r.rest, '/') != nullptr) throw DatabaseError(DatabaseErrorCode::NOT_FOUND, "Parent not found"); - Directory *mnt = r.directory->CreateChild(r.uri); + Directory *mnt = r.directory->CreateChild(r.rest); mnt->mounted_database = std::move(db); } @@ -461,7 +461,7 @@ SimpleDatabase::LockUmountSteal(const char *uri) noexcept ScopeDatabaseLock protect; auto r = root->LookupDirectory(uri); - if (r.uri != nullptr || !r.directory->IsMount()) + if (r.rest != nullptr || !r.directory->IsMount()) return nullptr; auto db = std::move(r.directory->mounted_database); diff --git a/src/db/update/Service.cxx b/src/db/update/Service.cxx index 9c1ec0b1a..d885381e4 100644 --- a/src/db/update/Service.cxx +++ b/src/db/update/Service.cxx @@ -192,17 +192,17 @@ UpdateService::Enqueue(const char *path, bool discard) if (db2 == nullptr) throw std::runtime_error("Cannot update this type of database"); - if (lr.uri == nullptr) { + if (lr.rest == nullptr) { storage2 = storage.GetMount(path); path = ""; } else { - assert(lr.uri > path); - assert(lr.uri < path + strlen(path)); - assert(lr.uri[-1] == '/'); + assert(lr.rest > path); + assert(lr.rest < path + strlen(path)); + assert(lr.rest[-1] == '/'); - const std::string mountpoint(path, lr.uri - 1); + const std::string mountpoint(path, lr.rest - 1); storage2 = storage.GetMount(mountpoint.c_str()); - path = lr.uri; + path = lr.rest; } } else { /* use the "root" database/storage */