From 628866a065535c43a1a0b45fd66ec5e186cb33ea Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 8 Jan 2009 07:36:40 +0100 Subject: update: save the database even if it is empty Save an empty database, even if the music directory is empty. --- src/database.h | 11 +++++++++++ src/update.c | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/database.h b/src/database.h index fdeab420a..f0f225108 100644 --- a/src/database.h +++ b/src/database.h @@ -69,4 +69,15 @@ db_load(void); time_t db_get_mtime(void); +/** + * Returns true if there is a valid database file on the disk. + */ +static inline bool +db_exists(void) +{ + /* mtime is set only if the database file was loaded or saved + successfully */ + return db_get_mtime() > 0; +} + #endif diff --git a/src/update.c b/src/update.c index 6aecd3265..ea8b3f820 100644 --- a/src/update.c +++ b/src/update.c @@ -647,8 +647,9 @@ static void * update_task(void *_path) updateDirectory(directory, &st); } - if (modified) + if (modified || !db_exists()) db_save(); + progress = UPDATE_PROGRESS_DONE; event_pipe_emit(PIPE_EVENT_UPDATE); return NULL; -- cgit v1.2.3