summaryrefslogtreecommitdiff
path: root/src/db
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2018-08-19 23:15:52 +0200
committerMax Kellermann <max@musicpd.org>2018-08-19 23:15:52 +0200
commitcc64c715a200836f40b3d231e8b01a64ce8e9eda (patch)
tree86e7f2fd719878e2cdb35a7b45fa029f8e3bd3c3 /src/db
parent9999914c740aed91f39f6b53ca78e6081d9ccdd4 (diff)
db/update/Service: Enqueue() throws on error
Diffstat (limited to 'src/db')
-rw-r--r--src/db/update/Service.cxx9
-rw-r--r--src/db/update/Service.hxx4
2 files changed, 8 insertions, 5 deletions
diff --git a/src/db/update/Service.cxx b/src/db/update/Service.cxx
index 9f7211933..debd9c432 100644
--- a/src/db/update/Service.cxx
+++ b/src/db/update/Service.cxx
@@ -26,6 +26,7 @@
#include "db/plugins/simple/SimpleDatabasePlugin.hxx"
#include "db/plugins/simple/Directory.hxx"
#include "storage/CompositeStorage.hxx"
+#include "protocol/Ack.hxx"
#include "Idle.hxx"
#include "Log.hxx"
#include "thread/Thread.hxx"
@@ -192,8 +193,7 @@ UpdateService::Enqueue(const char *path, bool discard)
Database &_db2 = *lr.directory->mounted_database;
if (!_db2.IsPlugin(simple_db_plugin))
- /* cannot update this type of database */
- return 0;
+ throw std::runtime_error("Cannot update this type of database");
db2 = static_cast<SimpleDatabase *>(&_db2);
@@ -219,12 +219,13 @@ UpdateService::Enqueue(const char *path, bool discard)
if (storage2 == nullptr)
/* no storage found at this mount point - should not
happen */
- return 0;
+ throw std::runtime_error("No storage at this path");
if (walk != nullptr) {
const unsigned id = GenerateId();
if (!queue.Push(*db2, *storage2, path, discard, id))
- return 0;
+ throw ProtocolError(ACK_ERROR_UPDATE_ALREADY,
+ "Update queue is full");
update_task_id = id;
return id;
diff --git a/src/db/update/Service.hxx b/src/db/update/Service.hxx
index e8818fd46..3f6284772 100644
--- a/src/db/update/Service.hxx
+++ b/src/db/update/Service.hxx
@@ -82,9 +82,11 @@ public:
/**
* Add this path to the database update queue.
*
+ * Throws on error
+ *
* @param path a path to update; if an empty string,
* the whole music directory is updated
- * @return the job id, or 0 on error
+ * @return the job id
*/
gcc_nonnull_all
unsigned Enqueue(const char *path, bool discard);