aboutsummaryrefslogtreecommitdiffstats
path: root/src/directory.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-10-04 21:01:17 -0700
committerEric Wong <normalperson@yhbt.net>2008-10-04 21:01:19 -0700
commit1533279fb18b2b0f53345f0e0727d2f0f968c00d (patch)
treef3f52d6360f884bceaa2715fcf95e6326a59ed56 /src/directory.c
parent3e0c1bcf6237f42506cd0d74046e74a70fff0cb7 (diff)
parentb84bf082df6ec5a7223c86abb94d799569aed1c1 (diff)
downloadmpd-1533279fb18b2b0f53345f0e0727d2f0f968c00d.tar.gz
mpd-1533279fb18b2b0f53345f0e0727d2f0f968c00d.tar.xz
mpd-1533279fb18b2b0f53345f0e0727d2f0f968c00d.zip
Merge commit 'box/song-locks' into ew/song-locks
* commit 'box/song-locks-wip': directory: reuse existing directory if found on update song: better handling of existing songs when rereading DB tag: merge clearMpdTag into tag_free song: start avoiding race in updateSongInfo
Diffstat (limited to 'src/directory.c')
-rw-r--r--src/directory.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/directory.c b/src/directory.c
index 1cd9da9eb..773b16db6 100644
--- a/src/directory.c
+++ b/src/directory.c
@@ -723,12 +723,13 @@ static void readDirectoryInfo(FILE * fp, Directory * directory)
char buffer[MPD_PATH_MAX * 2];
int bufferSize = MPD_PATH_MAX * 2;
char key[MPD_PATH_MAX * 2];
- Directory *subDirectory;
char *name;
while (myFgets(buffer, bufferSize, fp)
&& prefixcmp(buffer, DIRECTORY_END)) {
if (!prefixcmp(buffer, DIRECTORY_DIR)) {
+ Directory *subdir;
+
strcpy(key, &(buffer[strlen(DIRECTORY_DIR)]));
if (!myFgets(buffer, bufferSize, fp))
FATAL("Error reading db, fgets\n");
@@ -740,9 +741,13 @@ static void readDirectoryInfo(FILE * fp, Directory * directory)
if (prefixcmp(buffer, DIRECTORY_BEGIN))
FATAL("Error reading db at line: %s\n", buffer);
name = &(buffer[strlen(DIRECTORY_BEGIN)]);
- subDirectory = newDirectory(name, directory);
- dirvec_add(&directory->children, subDirectory);
- readDirectoryInfo(fp, subDirectory);
+ if ((subdir = getDirectory(name))) {
+ assert(subdir->parent == directory);
+ } else {
+ subdir = newDirectory(name, directory);
+ dirvec_add(&directory->children, subdir);
+ }
+ readDirectoryInfo(fp, subdir);
} else if (!prefixcmp(buffer, SONG_BEGIN)) {
readSongInfoIntoList(fp, directory);
} else {