call stat() a few less times on update
git-svn-id: https://svn.musicpd.org/mpd/trunk@1607 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
d7a56bb18c
commit
b019545756
@ -301,16 +301,18 @@ void deleteEmptyDirectoriesInDirectory(Directory * directory) {
|
|||||||
1 -> no error, and stuff updated
|
1 -> no error, and stuff updated
|
||||||
*/
|
*/
|
||||||
int updateInDirectory(Directory * directory, char * shortname, char * name) {
|
int updateInDirectory(Directory * directory, char * shortname, char * name) {
|
||||||
time_t mtime;
|
|
||||||
void * song;
|
void * song;
|
||||||
void * subDir;
|
void * subDir;
|
||||||
|
struct stat st;
|
||||||
|
|
||||||
if(isMusic(name,&mtime)) {
|
if(myStat(name, &st)) return -1;
|
||||||
|
|
||||||
|
if(S_ISREG(st.st_mode) && hasMusicSuffix(name)) {
|
||||||
if(0==findInList(directory->songs,shortname,&song)) {
|
if(0==findInList(directory->songs,shortname,&song)) {
|
||||||
addToDirectory(directory,shortname,name);
|
addToDirectory(directory,shortname,name);
|
||||||
return DIRECTORY_RETURN_UPDATE;
|
return DIRECTORY_RETURN_UPDATE;
|
||||||
}
|
}
|
||||||
else if(mtime!=((Song *)song)->mtime) {
|
else if(st.st_mtime!=((Song *)song)->mtime) {
|
||||||
LOG("updating %s\n",name);
|
LOG("updating %s\n",name);
|
||||||
if(updateSongInfo((Song *)song)<0) {
|
if(updateSongInfo((Song *)song)<0) {
|
||||||
removeSongFromDirectory(directory,shortname);
|
removeSongFromDirectory(directory,shortname);
|
||||||
@ -318,7 +320,7 @@ int updateInDirectory(Directory * directory, char * shortname, char * name) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(isDir(name)) {
|
else if(S_ISDIR(st.st_mode)) {
|
||||||
if(findInList(directory->subDirectories,shortname,(void **)&subDir)) {
|
if(findInList(directory->subDirectories,shortname,(void **)&subDir)) {
|
||||||
if(updateDirectory((Directory *)subDir)>0) return 1;
|
if(updateDirectory((Directory *)subDir)>0) return 1;
|
||||||
}
|
}
|
||||||
@ -648,10 +650,11 @@ int addSubDirectoryToDirectory(Directory * directory, char * shortname,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int addToDirectory(Directory * directory, char * shortname, char * name) {
|
int addToDirectory(Directory * directory, char * shortname, char * name) {
|
||||||
if(isDir(name)) {
|
struct stat st;
|
||||||
return addSubDirectoryToDirectory(directory,shortname,name);
|
|
||||||
}
|
if(myStat(name, &st)) return -1;
|
||||||
else if(isMusic(name,NULL)) {
|
|
||||||
|
if(S_ISREG(st.st_mode) && hasMusicSuffix(name)) {
|
||||||
Song * song;
|
Song * song;
|
||||||
song = addSongToList(directory->songs,shortname,name,
|
song = addSongToList(directory->songs,shortname,name,
|
||||||
SONG_TYPE_FILE);
|
SONG_TYPE_FILE);
|
||||||
@ -659,6 +662,9 @@ int addToDirectory(Directory * directory, char * shortname, char * name) {
|
|||||||
LOG("added %s\n",name);
|
LOG("added %s\n",name);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
else if(S_ISDIR(st.st_mode)) {
|
||||||
|
return addSubDirectoryToDirectory(directory,shortname,name);
|
||||||
|
}
|
||||||
|
|
||||||
DEBUG("addToDirectory: %s is not a directory or music\n",name);
|
DEBUG("addToDirectory: %s is not a directory or music\n",name);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user