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.
This commit is contained in:
Max Kellermann 2009-01-04 17:26:07 +01:00
parent 17d8bdb427
commit 599d5820bc

View File

@ -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;