aboutsummaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
Diffstat (limited to 'src/db')
-rw-r--r--src/db/plugins/simple/Directory.cxx18
-rw-r--r--src/db/plugins/simple/Directory.hxx11
-rw-r--r--src/db/plugins/simple/SimpleDatabasePlugin.cxx20
3 files changed, 19 insertions, 30 deletions
diff --git a/src/db/plugins/simple/Directory.cxx b/src/db/plugins/simple/Directory.cxx
index a81021b47..b4255b0ac 100644
--- a/src/db/plugins/simple/Directory.cxx
+++ b/src/db/plugins/simple/Directory.cxx
@@ -202,24 +202,6 @@ Directory::FindSong(const char *name_utf8) const
return nullptr;
}
-Song *
-Directory::LookupSong(const char *uri)
-{
- assert(holding_db_lock());
- assert(uri != nullptr);
-
- auto r = LookupDirectory(uri);
- if (r.uri == nullptr)
- /* it's a directory */
- return nullptr;
-
- if (strchr(r.uri, '/') != nullptr)
- /* refers to a URI "below" the actual song */
- return nullptr;
-
- return r.directory->FindSong(r.uri);
-}
-
static int
directory_cmp(gcc_unused void *priv,
struct list_head *_a, struct list_head *_b)
diff --git a/src/db/plugins/simple/Directory.hxx b/src/db/plugins/simple/Directory.hxx
index ab03092f7..5b39231e3 100644
--- a/src/db/plugins/simple/Directory.hxx
+++ b/src/db/plugins/simple/Directory.hxx
@@ -214,17 +214,6 @@ public:
}
/**
- * Looks up a song by its relative URI.
- *
- * Caller must lock the #db_mutex.
- *
- * @param uri the relative URI
- * @return the song, or nullptr if none was found
- */
- gcc_pure
- Song *LookupSong(const char *uri);
-
- /**
* Add a song object to this directory. Its "parent" attribute must
* be set already.
*/
diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.cxx b/src/db/plugins/simple/SimpleDatabasePlugin.cxx
index 8ba6eef92..e83ef575b 100644
--- a/src/db/plugins/simple/SimpleDatabasePlugin.cxx
+++ b/src/db/plugins/simple/SimpleDatabasePlugin.cxx
@@ -207,7 +207,25 @@ SimpleDatabase::GetSong(const char *uri, Error &error) const
assert(borrowed_song_count == 0);
db_lock();
- const Song *song = root->LookupSong(uri);
+
+ auto r = root->LookupDirectory(uri);
+ if (r.uri == nullptr) {
+ /* it's a directory */
+ db_unlock();
+ error.Format(db_domain, DB_NOT_FOUND,
+ "No such song: %s", uri);
+ return nullptr;
+ }
+
+ if (strchr(r.uri, '/') != nullptr) {
+ /* refers to a URI "below" the actual song */
+ db_unlock();
+ error.Format(db_domain, DB_NOT_FOUND,
+ "No such song: %s", uri);
+ return nullptr;
+ }
+
+ const Song *song = r.directory->FindSong(r.uri);
db_unlock();
if (song == nullptr) {
error.Format(db_domain, DB_NOT_FOUND,