aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-04-16 00:48:47 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-04-16 00:48:47 +0000
commitc4d2b8dc1cc73bd2229e1717b3ef6467bc7928d6 (patch)
treeff94065034089a8987acc1f7dab30121147b5508 /src
parent2e420db19cab6bf7849db02bf6b99e6bc58c40df (diff)
downloadmpd-c4d2b8dc1cc73bd2229e1717b3ef6467bc7928d6.tar.gz
mpd-c4d2b8dc1cc73bd2229e1717b3ef6467bc7928d6.tar.xz
mpd-c4d2b8dc1cc73bd2229e1717b3ef6467bc7928d6.zip
only write db in initMp3Directory() when stuff is updated
git-svn-id: https://svn.musicpd.org/mpd/trunk@781 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src')
-rw-r--r--src/directory.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/directory.c b/src/directory.c
index 726eae241..27652e3db 100644
--- a/src/directory.c
+++ b/src/directory.c
@@ -63,6 +63,10 @@
#define DIRECTORY_UPDATE_EXIT_UPDATE 1
#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 struct _Directory {
@@ -309,7 +313,7 @@ int updateInDirectory(Directory * directory, char * shortname, char * name) {
if(isMusic(name,&mtime)) {
if(0==findInList(directory->songs,shortname,&song)) {
addToDirectory(directory,shortname,name);
- return 1;
+ return DIRECTORY_RETURN_UPDATE;
}
else if(mtime!=((Song *)song)->mtime) {
LOG("updating %s\n",name);
@@ -960,13 +964,15 @@ int readDirectoryDB() {
return 0;
}
-/* return values:
- -1 -> error
- 0 -> no error, but nothing updated
- 1 -> no error, and stuff updated
- */
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");
myfprintf(fp,"%s problems updating music db\n",COMMAND_RESPOND_ERROR);
return -1;