diff options
author | Max Kellermann <max@duempel.org> | 2009-01-04 17:26:07 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-01-04 17:26:07 +0100 |
commit | 599d5820bce424625e54e2486191437a012ff1dc (patch) | |
tree | 5c23c9ba56f859c076dbc9add28d6efe51612dc5 /src | |
parent | 17d8bdb427eb179b06bff8f9229decafc93de1d6 (diff) | |
download | mpd-599d5820bce424625e54e2486191437a012ff1dc.tar.gz mpd-599d5820bce424625e54e2486191437a012ff1dc.tar.xz mpd-599d5820bce424625e54e2486191437a012ff1dc.zip |
update: moved code to directory_exists(), fix typo
Reverse the condition: delete directories which don't exist anymore.
This typo caused a slowdown during partial database update.
Diffstat (limited to 'src')
-rw-r--r-- | src/update.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/update.c b/src/update.c index 853aa9d8d..eaffebb10 100644 --- a/src/update.c +++ b/src/update.c @@ -190,6 +190,23 @@ delete_song_if_removed(struct song *song, void *_data) return 0; } +static bool +directory_exists(const struct directory *directory) +{ + char *path_fs; + bool exists; + + path_fs = map_directory_fs(directory); + if (path_fs == NULL) + /* invalid path: cannot exist */ + return false; + + exists = g_file_test(path_fs, G_FILE_TEST_IS_DIR); + g_free(path_fs); + + return exists; +} + static void removeDeletedFromDirectory(struct directory *directory) { @@ -198,17 +215,9 @@ removeDeletedFromDirectory(struct directory *directory) struct delete_data data; for (i = dv->nr; --i >= 0; ) { - char *path_fs; - bool is_dir; - - path_fs = map_directory_fs(dv->base[i]); - if (path_fs == NULL) + if (directory_exists(dv->base[i])) continue; - is_dir = g_file_test(path_fs, G_FILE_TEST_IS_DIR); - g_free(path_fs); - if (!is_dir) - continue; g_debug("removing directory: %s", dv->base[i]->path); dirvec_delete(dv, dv->base[i]); modified = true; |