aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-09 19:11:54 +0200
committerEric Wong <normalperson@yhbt.net>2008-10-11 19:21:50 -0700
commit6fd08bc8fad5d6c4be37ce751d53ef80b756b292 (patch)
tree11de3cf6fb40a9af6a1d0e43180293bde6ad5cec /src
parent1f70121c5604be45e81c5a07d59efea2aaa1597b (diff)
downloadmpd-6fd08bc8fad5d6c4be37ce751d53ef80b756b292.tar.gz
mpd-6fd08bc8fad5d6c4be37ce751d53ef80b756b292.tar.xz
mpd-6fd08bc8fad5d6c4be37ce751d53ef80b756b292.zip
update: don't export updateDirectory()
If the user requests database update during startup, call directory_update_init(). This should be changed to fully asynchronous update later. For this to work, main_notify has to be initialized before db_init().
Diffstat (limited to '')
-rw-r--r--src/database.c10
-rw-r--r--src/main.c3
-rw-r--r--src/update.c10
-rw-r--r--src/update.h10
4 files changed, 20 insertions, 13 deletions
diff --git a/src/database.c b/src/database.c
index 11de15bcc..3a1667bb6 100644
--- a/src/database.c
+++ b/src/database.c
@@ -39,7 +39,15 @@ static time_t directory_dbModTime;
void db_init(void)
{
music_root = directory_new("", NULL);
- updateDirectory(music_root);
+
+ if (directory_update_init(NULL) < 0)
+ FATAL("directory update failed\n");
+
+ do {
+ my_usleep(100000);
+ reap_update_task();
+ } while (isUpdatingDB());
+
stats.numberOfSongs = countSongsIn(NULL);
stats.dbPlayTime = sumSongTimesIn(NULL);
}
diff --git a/src/main.c b/src/main.c
index 07f0f528a..f1c288dd5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -409,6 +409,8 @@ int main(int argc, char *argv[])
initPlaylist();
initInputPlugins();
+ init_main_notify();
+
openDB(&options, argv[0]);
initCommands();
@@ -424,7 +426,6 @@ int main(int argc, char *argv[])
daemonize(&options);
- init_main_notify();
init_output_buffer();
setup_log_output(options.stdOutput);
diff --git a/src/update.c b/src/update.c
index 49850256c..641b1d63b 100644
--- a/src/update.c
+++ b/src/update.c
@@ -28,6 +28,12 @@
#include "condition.h"
#include "update.h"
+enum update_return {
+ UPDATE_RETURN_ERROR = -1,
+ UPDATE_RETURN_NOUPDATE = 0,
+ UPDATE_RETURN_UPDATED = 1
+};
+
enum update_progress {
UPDATE_PROGRESS_IDLE = 0,
UPDATE_PROGRESS_RUNNING = 1,
@@ -194,6 +200,8 @@ inodeFoundInParent(struct directory *parent, ino_t inode, dev_t device)
return 0;
}
+static enum update_return updateDirectory(struct directory *directory);
+
static enum update_return
addSubDirectoryToDirectory(struct directory *directory,
const char *name, const struct stat *st)
@@ -269,7 +277,7 @@ static int skip_path(const char *path)
return (path[0] == '.' || strchr(path, '\n')) ? 1 : 0;
}
-enum update_return updateDirectory(struct directory *directory)
+static enum update_return updateDirectory(struct directory *directory)
{
int was_empty = directory_is_empty(directory);
DIR *dir;
diff --git a/src/update.h b/src/update.h
index 65ffdc3bf..0c0d74416 100644
--- a/src/update.h
+++ b/src/update.h
@@ -20,18 +20,8 @@
#ifndef UPDATE_H
#define UPDATE_H
-struct directory;
-
-enum update_return {
- UPDATE_RETURN_ERROR = -1,
- UPDATE_RETURN_NOUPDATE = 0,
- UPDATE_RETURN_UPDATED = 1
-};
-
int isUpdatingDB(void);
-enum update_return updateDirectory(struct directory *directory);
-
/*
* returns the non-negative update job ID on success,
* returns -1 if busy