update: save the database even if it is empty
Save an empty database, even if the music directory is empty.
This commit is contained in:
@@ -69,4 +69,15 @@ db_load(void);
|
|||||||
time_t
|
time_t
|
||||||
db_get_mtime(void);
|
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
|
#endif
|
||||||
|
@@ -647,8 +647,9 @@ static void * update_task(void *_path)
|
|||||||
updateDirectory(directory, &st);
|
updateDirectory(directory, &st);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modified)
|
if (modified || !db_exists())
|
||||||
db_save();
|
db_save();
|
||||||
|
|
||||||
progress = UPDATE_PROGRESS_DONE;
|
progress = UPDATE_PROGRESS_DONE;
|
||||||
event_pipe_emit(PIPE_EVENT_UPDATE);
|
event_pipe_emit(PIPE_EVENT_UPDATE);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Reference in New Issue
Block a user