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().
This commit is contained in:
parent
0677116da0
commit
7dd099a60f
@ -29,6 +29,7 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "dbUtils.h"
|
#include "dbUtils.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
|
#include "main_notify.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -40,8 +41,19 @@ static time_t directory_dbModTime;
|
|||||||
void
|
void
|
||||||
db_init(void)
|
db_init(void)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
music_root = directory_new("", NULL);
|
music_root = directory_new("", NULL);
|
||||||
updateDirectory(music_root);
|
|
||||||
|
ret = directory_update_init(NULL);
|
||||||
|
if (ret < 0)
|
||||||
|
FATAL("directory update failed\n");
|
||||||
|
|
||||||
|
do {
|
||||||
|
wait_main_task();
|
||||||
|
reap_update_task();
|
||||||
|
} while (isUpdatingDB());
|
||||||
|
|
||||||
stats.numberOfSongs = countSongsIn(NULL);
|
stats.numberOfSongs = countSongsIn(NULL);
|
||||||
stats.dbPlayTime = sumSongTimesIn(NULL);
|
stats.dbPlayTime = sumSongTimesIn(NULL);
|
||||||
}
|
}
|
||||||
|
@ -412,6 +412,8 @@ int main(int argc, char *argv[])
|
|||||||
initPlaylist();
|
initPlaylist();
|
||||||
decoder_plugin_init_all();
|
decoder_plugin_init_all();
|
||||||
|
|
||||||
|
init_main_notify();
|
||||||
|
|
||||||
openDB(&options, argv[0]);
|
openDB(&options, argv[0]);
|
||||||
|
|
||||||
initCommands();
|
initCommands();
|
||||||
@ -429,7 +431,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
daemonize(&options);
|
daemonize(&options);
|
||||||
|
|
||||||
init_main_notify();
|
|
||||||
setup_log_output(options.stdOutput);
|
setup_log_output(options.stdOutput);
|
||||||
|
|
||||||
initSigHandlers();
|
initSigHandlers();
|
||||||
|
11
src/update.c
11
src/update.c
@ -30,6 +30,12 @@
|
|||||||
#include "condition.h"
|
#include "condition.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
|
|
||||||
|
enum update_return {
|
||||||
|
UPDATE_RETURN_ERROR = -1,
|
||||||
|
UPDATE_RETURN_NOUPDATE = 0,
|
||||||
|
UPDATE_RETURN_UPDATED = 1
|
||||||
|
};
|
||||||
|
|
||||||
enum update_progress {
|
enum update_progress {
|
||||||
UPDATE_PROGRESS_IDLE = 0,
|
UPDATE_PROGRESS_IDLE = 0,
|
||||||
UPDATE_PROGRESS_RUNNING = 1,
|
UPDATE_PROGRESS_RUNNING = 1,
|
||||||
@ -203,6 +209,9 @@ inodeFoundInParent(struct directory *parent, ino_t inode, dev_t device)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static enum update_return
|
||||||
|
updateDirectory(struct directory *directory);
|
||||||
|
|
||||||
static enum update_return
|
static enum update_return
|
||||||
addSubDirectoryToDirectory(struct directory *directory,
|
addSubDirectoryToDirectory(struct directory *directory,
|
||||||
const char *name, const struct stat *st)
|
const char *name, const struct stat *st)
|
||||||
@ -280,7 +289,7 @@ static int skip_path(const char *path)
|
|||||||
return (path[0] == '.' || strchr(path, '\n')) ? 1 : 0;
|
return (path[0] == '.' || strchr(path, '\n')) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum update_return
|
static enum update_return
|
||||||
updateDirectory(struct directory *directory)
|
updateDirectory(struct directory *directory)
|
||||||
{
|
{
|
||||||
bool was_empty = directory_is_empty(directory);
|
bool was_empty = directory_is_empty(directory);
|
||||||
|
11
src/update.h
11
src/update.h
@ -20,19 +20,8 @@
|
|||||||
#ifndef UPDATE_H
|
#ifndef UPDATE_H
|
||||||
#define 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);
|
int isUpdatingDB(void);
|
||||||
|
|
||||||
enum update_return
|
|
||||||
updateDirectory(struct directory *directory);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* returns the non-negative update job ID on success,
|
* returns the non-negative update job ID on success,
|
||||||
* returns -1 if busy
|
* returns -1 if busy
|
||||||
|
Loading…
x
Reference in New Issue
Block a user