only write db in initMp3Directory() when stuff is updated
git-svn-id: https://svn.musicpd.org/mpd/trunk@781 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
2e420db19c
commit
c4d2b8dc1c
@ -63,6 +63,10 @@
|
|||||||
#define DIRECTORY_UPDATE_EXIT_UPDATE 1
|
#define DIRECTORY_UPDATE_EXIT_UPDATE 1
|
||||||
#define DIRECTORY_UPDATE_EXIT_ERROR 2
|
#define DIRECTORY_UPDATE_EXIT_ERROR 2
|
||||||
|
|
||||||
|
#define DIRECTORY_RETURN_NOUPDATE 0
|
||||||
|
#define DIRECTORY_RETURN_UPDATE 1
|
||||||
|
#define DIRECTORY_RETURN_ERROR -1
|
||||||
|
|
||||||
typedef List DirectoryList;
|
typedef List DirectoryList;
|
||||||
|
|
||||||
typedef struct _Directory {
|
typedef struct _Directory {
|
||||||
@ -309,7 +313,7 @@ int updateInDirectory(Directory * directory, char * shortname, char * name) {
|
|||||||
if(isMusic(name,&mtime)) {
|
if(isMusic(name,&mtime)) {
|
||||||
if(0==findInList(directory->songs,shortname,&song)) {
|
if(0==findInList(directory->songs,shortname,&song)) {
|
||||||
addToDirectory(directory,shortname,name);
|
addToDirectory(directory,shortname,name);
|
||||||
return 1;
|
return DIRECTORY_RETURN_UPDATE;
|
||||||
}
|
}
|
||||||
else if(mtime!=((Song *)song)->mtime) {
|
else if(mtime!=((Song *)song)->mtime) {
|
||||||
LOG("updating %s\n",name);
|
LOG("updating %s\n",name);
|
||||||
@ -960,13 +964,15 @@ int readDirectoryDB() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return values:
|
|
||||||
-1 -> error
|
|
||||||
0 -> no error, but nothing updated
|
|
||||||
1 -> no error, and stuff updated
|
|
||||||
*/
|
|
||||||
int updateMp3Directory(FILE * fp) {
|
int updateMp3Directory(FILE * fp) {
|
||||||
if(updateDirectory(mp3rootDirectory)<0) {
|
switch(updateDirectory(mp3rootDirectory)) {
|
||||||
|
case 0:
|
||||||
|
/* nothing updated */
|
||||||
|
return 0;
|
||||||
|
case 1:
|
||||||
|
/* something was updated and db should be written */
|
||||||
|
break;
|
||||||
|
default:
|
||||||
ERROR("problems updating music db\n");
|
ERROR("problems updating music db\n");
|
||||||
myfprintf(fp,"%s problems updating music db\n",COMMAND_RESPOND_ERROR);
|
myfprintf(fp,"%s problems updating music db\n",COMMAND_RESPOND_ERROR);
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user