diff options
Diffstat (limited to '')
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | src/database.h | 12 | ||||
-rw-r--r-- | src/update.c | 3 |
3 files changed, 15 insertions, 1 deletions
@@ -6,6 +6,7 @@ MPD 0.14.1 - not yet released - jack: allocate default port names (fixes a crash) * update: - refresh stats after update + - save the database even if it is empty * log: automatically append newline * fix setenv() conflict on Solaris * configure.ac: check for pkg-config before using it diff --git a/src/database.h b/src/database.h index b6884b604..ff17e3eb0 100644 --- a/src/database.h +++ b/src/database.h @@ -20,6 +20,7 @@ #ifndef MPD_DATABASE_H #define MPD_DATABASE_H +#include <stdbool.h> #include <sys/time.h> struct directory; @@ -55,4 +56,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 10108f0a9..58f1b08d1 100644 --- a/src/update.c +++ b/src/update.c @@ -518,8 +518,9 @@ static void * update_task(void *_path) updateDirectory(directory, &st); } - if (modified) + if (modified || !db_exists()) db_save(); + progress = UPDATE_PROGRESS_DONE; wakeup_main_task(); return NULL; |