aboutsummaryrefslogtreecommitdiffstats
path: root/src/inotify_update.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-02-13 20:10:19 +0100
committerMax Kellermann <max@duempel.org>2012-02-13 20:10:19 +0100
commit0a0b473765fe5ba43f442e3d12853add3ff51415 (patch)
treee6abfddf8066f1c9cf7ab0836505303ad0457ce0 /src/inotify_update.c
parentdf2d0414837ec0b53836f9c32e0f93d3baaefb14 (diff)
downloadmpd-0a0b473765fe5ba43f442e3d12853add3ff51415.tar.gz
mpd-0a0b473765fe5ba43f442e3d12853add3ff51415.tar.xz
mpd-0a0b473765fe5ba43f442e3d12853add3ff51415.zip
mapper: add mapper_get_music_directory()
Shortcut for map_directory_fs(db_get_root()).
Diffstat (limited to 'src/inotify_update.c')
-rw-r--r--src/inotify_update.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/src/inotify_update.c b/src/inotify_update.c
index e78c15fc1..02e55ee0b 100644
--- a/src/inotify_update.c
+++ b/src/inotify_update.c
@@ -266,18 +266,19 @@ mpd_inotify_callback(int wd, unsigned mask,
(mask & IN_ISDIR) != 0) {
/* a sub directory was changed: register those in
inotify */
- char *root = map_directory_fs(db_get_root());
- char *path_fs;
-
- if (uri_fs != NULL) {
- path_fs = g_strconcat(root, "/", uri_fs, NULL);
- g_free(root);
- } else
+ const char *root = mapper_get_music_directory();
+ const char *path_fs;
+ char *allocated = NULL;
+
+ if (uri_fs != NULL)
+ path_fs = allocated =
+ g_strconcat(root, "/", uri_fs, NULL);
+ else
path_fs = root;
recursive_watch_subdirectories(directory, path_fs,
watch_directory_depth(directory));
- g_free(path_fs);
+ g_free(allocated);
}
if ((mask & (IN_CLOSE_WRITE|IN_MOVE|IN_DELETE)) != 0 ||
@@ -303,21 +304,13 @@ mpd_inotify_callback(int wd, unsigned mask,
void
mpd_inotify_init(unsigned max_depth)
{
- struct directory *root;
- char *path;
GError *error = NULL;
g_debug("initializing inotify");
- root = db_get_root();
- if (root == NULL) {
- g_debug("no music directory configured");
- return;
- }
-
- path = map_directory_fs(root);
+ const char *path = mapper_get_music_directory();
if (path == NULL) {
- g_warning("mapper has failed");
+ g_debug("no music directory configured");
return;
}
@@ -326,13 +319,12 @@ mpd_inotify_init(unsigned max_depth)
if (inotify_source == NULL) {
g_warning("%s", error->message);
g_error_free(error);
- g_free(path);
return;
}
inotify_max_depth = max_depth;
- inotify_root.name = path;
+ inotify_root.name = g_strdup(path);
inotify_root.descriptor = mpd_inotify_source_add(inotify_source, path,
IN_MASK, &error);
if (inotify_root.descriptor < 0) {
@@ -340,7 +332,6 @@ mpd_inotify_init(unsigned max_depth)
g_error_free(error);
mpd_inotify_source_free(inotify_source);
inotify_source = NULL;
- g_free(path);
return;
}