aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-06-23 04:20:35 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-06-23 04:20:35 +0000
commitb8d2ef8768b4ec72f9c81fe49e88ed77ad655663 (patch)
treea2477a247d36506b3e1eda77fde44b693786f3e3
parent0083b0739593d60f0673949cc57f85f18a883e75 (diff)
downloadmpd-b8d2ef8768b4ec72f9c81fe49e88ed77ad655663.tar.gz
mpd-b8d2ef8768b4ec72f9c81fe49e88ed77ad655663.tar.xz
mpd-b8d2ef8768b4ec72f9c81fe49e88ed77ad655663.zip
update now ignores/recognizes recursive directories
git-svn-id: https://svn.musicpd.org/mpd/trunk@1623 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/directory.c45
1 files changed, 41 insertions, 4 deletions
diff --git a/src/directory.c b/src/directory.c
index 2954e054e..d15894633 100644
--- a/src/directory.c
+++ b/src/directory.c
@@ -126,6 +126,8 @@ void sortDirectory(Directory * directory);
int inodeFoundInParent(Directory * parent, ino_t inode, dev_t device);
+int statDirectory(Directory * dir);
+
void clearUpdatePid() {
directory_updatePid = 0;
}
@@ -345,7 +347,9 @@ int updateInDirectory(Directory * directory, char * shortname, char * name) {
}
else if(S_ISDIR(st.st_mode)) {
if(findInList(directory->subDirectories,shortname,(void **)&subDir)) {
- if(updateDirectory((Directory *)subDir)>0) return 1;
+ freeDirectoryStatFromDirectory(subDir);
+ ((Directory *)subDir)->stat = newDirectoryStat(&st);
+ return updateDirectory((Directory *)subDir);
}
else {
return addSubDirectoryToDirectory(directory,shortname,
@@ -523,8 +527,18 @@ int updatePath(char * utf8path) {
}
}
else if((song = getSongDetails(path,&shortname,&parentDirectory))) {
+ if(!parentDirectory->stat && statDirectory(parentDirectory) < 0)
+ {
+ free(path);
+ return 0;
+ }
/* if this song update is successfull, we are done */
- if(song && isMusic(song->utf8url,&mtime)) {
+ else if(0 == inodeFoundInParent(
+ parentDirectory->parent,
+ parentDirectory->stat->inode,
+ parentDirectory->stat->device) &&
+ song && isMusic(song->utf8url,&mtime))
+ {
free(path);
if(song->mtime==mtime) return 0;
else if(updateSongInfo(song)==0) return 1;
@@ -548,7 +562,17 @@ int updatePath(char * utf8path) {
*/
if(isDir(path) || isMusic(path,NULL)) {
parentDirectory = addParentPathToDB(path,&shortname);
- if(addToDirectory(parentDirectory,shortname,path)>0) ret = 1;
+ if(!parentDirectory->stat && statDirectory(parentDirectory) < 0)
+ {
+ }
+ else if(inodeFoundInParent(parentDirectory->parent,
+ parentDirectory->stat->inode,
+ parentDirectory->stat->device))
+ {
+ }
+ else if(addToDirectory(parentDirectory,shortname,path)>0) {
+ ret = 1;
+ }
}
free(path);
@@ -570,6 +594,18 @@ int updateDirectory(Directory * directory) {
char * dirname = directory->utf8name;
int ret = 0;
+ {
+ if(!directory->stat && statDirectory(directory) < 0) {
+ return -1;
+ }
+ else if(inodeFoundInParent(directory->parent,
+ directory->stat->inode,
+ directory->stat->device))
+ {
+ return -1;
+ }
+ }
+
cwd[0] = '.';
cwd[1] = '\0';
if(dirname==NULL) dirname=cwd;
@@ -672,6 +708,7 @@ int inodeFoundInParent(Directory * parent, ino_t inode, dev_t device) {
if(parent->stat->inode == inode &&
parent->stat->device == device)
{
+ DEBUG("recursive directory found\n");
return 1;
}
parent = parent->parent;
@@ -1265,7 +1302,7 @@ void freeAllDirectoryStats(Directory * directory) {
ListNode * node = directory->subDirectories->firstNode;
while(node != NULL) {
- freeAllDirectoryStats(directory);
+ freeAllDirectoryStats((Directory *)node->data);
node = node->nextNode;
}