aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/command.c12
-rw-r--r--src/update.c11
2 files changed, 17 insertions, 6 deletions
diff --git a/src/command.c b/src/command.c
index f583f82a1..04e85c6fe 100644
--- a/src/command.c
+++ b/src/command.c
@@ -802,9 +802,15 @@ static int handleUpdate(int fd, mpd_unused int *permission,
char *path = NULL;
assert(argc <= 2);
- if (argc == 2 && !(path = sanitizePathDup(argv[1]))) {
- commandError(fd, ACK_ERROR_ARG, "invalid path");
- return -1;
+ if (argc == 2) {
+ if (!(path = sanitizePathDup(argv[1]))) {
+ commandError(fd, ACK_ERROR_ARG, "invalid path");
+ return -1;
+ }
+ if (path_is_music_root(path)) {
+ free(path);
+ path = NULL;
+ }
}
return print_update_result(fd, directory_update_init(path));
}
diff --git a/src/update.c b/src/update.c
index 72f4b943b..6c8b6e7bc 100644
--- a/src/update.c
+++ b/src/update.c
@@ -349,9 +349,12 @@ static void updatePath(const char *utf8path)
static void * update_task(void *_path)
{
- if (_path && !path_is_music_root(_path)) {
- updatePath(_path);
- free(_path);
+ char *utf8path = _path;
+
+ if (utf8path) {
+ assert(*utf8path);
+ updatePath(utf8path);
+ free(utf8path);
} else {
struct stat st;
@@ -386,6 +389,8 @@ unsigned directory_update_init(char *path)
{
assert(pthread_equal(pthread_self(), main_task));
+ assert(!path || (path && *path));
+
if (progress != UPDATE_PROGRESS_IDLE) {
unsigned next_task_id;