aboutsummaryrefslogtreecommitdiffstats
path: root/src/directory.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-04-11 17:37:47 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-04-11 17:37:47 +0000
commitfc7a264e4d3f6ba93d52722455e6d4ec7ca671fb (patch)
treec55738667ba5973be0435fd54048269013ae89c2 /src/directory.c
parent87f53c94d7361bb3aaa1369d26f76f049905fc82 (diff)
downloadmpd-fc7a264e4d3f6ba93d52722455e6d4ec7ca671fb.tar.gz
mpd-fc7a264e4d3f6ba93d52722455e6d4ec7ca671fb.tar.xz
mpd-fc7a264e4d3f6ba93d52722455e6d4ec7ca671fb.zip
incremental updates and command-list/update kung fu
this needs some serious cleaning up and testing git-svn-id: https://svn.musicpd.org/mpd/trunk@692 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/directory.c55
1 files changed, 52 insertions, 3 deletions
diff --git a/src/directory.c b/src/directory.c
index ec4b1f19d..d34c0d553 100644
--- a/src/directory.c
+++ b/src/directory.c
@@ -90,8 +90,15 @@ int updateDirectory(Directory * directory);
void deleteEmptyDirectoriesInDirectory(Directory * directory);
+void removeSongFromDirectory(Directory * directory, char * shortname);
+
int addSubDirectoryToDirectory(Directory * directory, char * shortname, char * name);
+Directory * getDirectory(char * name);
+
+Song * getSongDetails(char * file, char ** shortnameRet,
+ Directory ** directoryRet);
+
int isUpdatingDB() {
if(directory_updatePid>0) return directory_updateJobId;
return 0;
@@ -114,7 +121,7 @@ void directory_sigChldHandler(int pid, int status) {
}
}
-int updateInit(FILE * fp) {
+int updateInit(FILE * fp, List * pathList) {
if(directory_updatePid > 0) {
myfprintf(fp,"%s already updating\n",COMMAND_RESPOND_ERROR);
return -1;
@@ -137,7 +144,41 @@ int updateInit(FILE * fp) {
finishPlaylist();
finishVolume();
- if(updateMp3Directory(stderr)) exit(EXIT_FAILURE);
+ if(pathList) {
+ ListNode * node = pathList->firstNode;
+ Directory * directory;
+ Song * song;
+ char * shortname;
+
+ while(node) {
+ if(NULL==(directory = getDirectory(node->key)))
+ {
+ song = getSongDetails(node->key,
+ &shortname,&directory);
+ if(song && updateSongInfo(song)<0) {
+ removeSongFromDirectory(
+ directory,
+ shortname);
+ }
+ }
+ else {
+ if(updateDirectory(directory)<0) {
+ ERROR("problems updating music "
+ "db\n");
+ exit(EXIT_FAILURE);
+ }
+ }
+ node = node->nextNode;
+ }
+ }
+ else if(updateDirectory(mp3rootDirectory)<0) exit(EXIT_FAILURE);
+ if(writeDirectoryDB()<0) {
+ ERROR("problems writing music db file, \"%s\"\n",
+ directorydb);
+ myfprintf(fp,"%s problems writing music db\n",
+ COMMAND_RESPOND_ERROR);
+ exit(EXIT_FAILURE);
+ }
exit(EXIT_SUCCESS);
}
else if(directory_updatePid < 0) {
@@ -950,7 +991,9 @@ void initMp3Directory() {
exploreDirectory(mp3rootDirectory);
}
-Song * getSong(char * file) {
+Song * getSongDetails(char * file, char ** shortnameRet,
+ Directory ** directoryRet)
+{
void * song;
Directory * directory;
char * dir = NULL;
@@ -983,9 +1026,15 @@ Song * getSong(char * file) {
}
free(dup);
+ if(shortnameRet) *shortnameRet = shortname;
+ if(directoryRet) *directoryRet = directory;
return (Song *)song;
}
+Song * getSong(char * file) {
+ return getSongDetails(file,NULL,NULL);
+}
+
time_t getDbModTime() {
time_t mtime = 0;
struct stat st;