Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
cc64c715
Commit
cc64c715
authored
Aug 19, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/update/Service: Enqueue() throws on error
parent
9999914c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
15 deletions
+11
-15
Main.cxx
src/Main.cxx
+1
-3
OtherCommands.cxx
src/command/OtherCommands.cxx
+2
-7
Service.cxx
src/db/update/Service.cxx
+5
-4
Service.hxx
src/db/update/Service.hxx
+3
-1
No files found.
src/Main.cxx
View file @
cc64c715
...
...
@@ -617,9 +617,7 @@ mpd_main_after_fork(const ConfigData &raw_config, const Config &config)
if
(
create_db
)
{
/* the database failed to load: recreate the
database */
unsigned
job
=
instance
->
update
->
Enqueue
(
""
,
true
);
if
(
job
==
0
)
throw
std
::
runtime_error
(
"directory update failed"
);
instance
->
update
->
Enqueue
(
""
,
true
);
}
#endif
...
...
src/command/OtherCommands.cxx
View file @
cc64c715
...
...
@@ -249,13 +249,8 @@ handle_update(Response &r, UpdateService &update,
const
char
*
uri_utf8
,
bool
discard
)
{
unsigned
ret
=
update
.
Enqueue
(
uri_utf8
,
discard
);
if
(
ret
>
0
)
{
r
.
Format
(
"updating_db: %i
\n
"
,
ret
);
return
CommandResult
::
OK
;
}
else
{
r
.
Error
(
ACK_ERROR_UPDATE_ALREADY
,
"already updating"
);
return
CommandResult
::
ERROR
;
}
r
.
Format
(
"updating_db: %i
\n
"
,
ret
);
return
CommandResult
::
OK
;
}
static
CommandResult
...
...
src/db/update/Service.cxx
View file @
cc64c715
...
...
@@ -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
;
...
...
src/db/update/Service.hxx
View file @
cc64c715
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment