only call opendir() once when updating
git-svn-id: https://svn.musicpd.org/mpd/trunk@1608 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
b019545756
commit
8933f5d416
@ -338,8 +338,7 @@ int updateInDirectory(Directory * directory, char * shortname, char * name) {
|
||||
0 -> no error, but nothing removed
|
||||
1 -> no error, and stuff removed
|
||||
*/
|
||||
int removeDeletedFromDirectory(Directory * directory) {
|
||||
DIR * dir;
|
||||
int removeDeletedFromDirectory(Directory * directory, DIR * dir) {
|
||||
char cwd[2];
|
||||
struct dirent * ent;
|
||||
char * dirname = directory->utf8name;
|
||||
@ -355,8 +354,6 @@ int removeDeletedFromDirectory(Directory * directory) {
|
||||
cwd[1] = '\0';
|
||||
if(dirname==NULL) dirname=cwd;
|
||||
|
||||
if((dir = opendir(rmp2amp(utf8ToFsCharset(dirname))))==NULL) return -1;
|
||||
|
||||
while((ent = readdir(dir))) {
|
||||
if(ent->d_name[0]=='.') continue; /* hide hidden stuff */
|
||||
if(strchr(ent->d_name, '\n')) continue;
|
||||
@ -373,8 +370,6 @@ int removeDeletedFromDirectory(Directory * directory) {
|
||||
insertInList(entList,utf8,s);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
|
||||
node = directory->subDirectories->firstNode;
|
||||
while(node) {
|
||||
tmpNode = node->nextNode;
|
||||
@ -556,10 +551,12 @@ int updateDirectory(Directory * directory) {
|
||||
cwd[1] = '\0';
|
||||
if(dirname==NULL) dirname=cwd;
|
||||
|
||||
if(removeDeletedFromDirectory(directory)>0) ret = 1;
|
||||
|
||||
if((dir = opendir(rmp2amp(utf8ToFsCharset(dirname))))==NULL) return -1;
|
||||
|
||||
if(removeDeletedFromDirectory(directory, dir)>0) ret = 1;
|
||||
|
||||
rewinddir(dir);
|
||||
|
||||
while((ent = readdir(dir))) {
|
||||
if(ent->d_name[0]=='.') continue; /* hide hidden stuff */
|
||||
if(strchr(ent->d_name, '\n')) continue;
|
||||
|
Loading…
Reference in New Issue
Block a user