directory: require db lock for _{add,remove}_song()

This commit is contained in:
Max Kellermann 2012-06-13 21:23:34 +02:00
parent 1a59730782
commit 9f3db5a70b
2 changed files with 10 additions and 0 deletions

View File

@ -186,6 +186,7 @@ directory_lookup_directory(struct directory *directory, const char *uri)
void void
directory_add_song(struct directory *directory, struct song *song) directory_add_song(struct directory *directory, struct song *song)
{ {
assert(holding_db_lock());
assert(directory != NULL); assert(directory != NULL);
assert(song != NULL); assert(song != NULL);
assert(song->parent == directory); assert(song->parent == directory);
@ -197,6 +198,7 @@ void
directory_remove_song(G_GNUC_UNUSED struct directory *directory, directory_remove_song(G_GNUC_UNUSED struct directory *directory,
struct song *song) struct song *song)
{ {
assert(holding_db_lock());
assert(directory != NULL); assert(directory != NULL);
assert(song != NULL); assert(song != NULL);
assert(song->parent == directory); assert(song->parent == directory);

View File

@ -236,7 +236,10 @@ update_archive_tree(struct directory *directory, char *name)
if (song == NULL) { if (song == NULL) {
song = song_file_load(name, directory); song = song_file_load(name, directory);
if (song != NULL) { if (song != NULL) {
db_lock();
directory_add_song(directory, song); directory_add_song(directory, song);
db_unlock();
modified = true; modified = true;
g_message("added %s/%s", g_message("added %s/%s",
directory_get_path(directory), name); directory_get_path(directory), name);
@ -374,7 +377,9 @@ update_container_file(struct directory *directory,
&add_tag_handler, song->tag); &add_tag_handler, song->tag);
g_free(child_path_fs); g_free(child_path_fs);
db_lock();
directory_add_song(contdir, song); directory_add_song(contdir, song);
db_unlock();
modified = true; modified = true;
@ -438,7 +443,10 @@ update_song_file(struct directory *directory,
return; return;
} }
db_lock();
directory_add_song(directory, song); directory_add_song(directory, song);
db_unlock();
modified = true; modified = true;
g_message("added %s/%s", g_message("added %s/%s",
directory_get_path(directory), name); directory_get_path(directory), name);