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:
parent
17d8bdb427
commit
599d5820bc
27
src/update.c
27
src/update.c
@ -190,6 +190,23 @@ delete_song_if_removed(struct song *song, void *_data)
|
|||||||
return 0;
|
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
|
static void
|
||||||
removeDeletedFromDirectory(struct directory *directory)
|
removeDeletedFromDirectory(struct directory *directory)
|
||||||
{
|
{
|
||||||
@ -198,17 +215,9 @@ removeDeletedFromDirectory(struct directory *directory)
|
|||||||
struct delete_data data;
|
struct delete_data data;
|
||||||
|
|
||||||
for (i = dv->nr; --i >= 0; ) {
|
for (i = dv->nr; --i >= 0; ) {
|
||||||
char *path_fs;
|
if (directory_exists(dv->base[i]))
|
||||||
bool is_dir;
|
|
||||||
|
|
||||||
path_fs = map_directory_fs(dv->base[i]);
|
|
||||||
if (path_fs == NULL)
|
|
||||||
continue;
|
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);
|
g_debug("removing directory: %s", dv->base[i]->path);
|
||||||
dirvec_delete(dv, dv->base[i]);
|
dirvec_delete(dv, dv->base[i]);
|
||||||
modified = true;
|
modified = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user