]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - mood.c
Complete afs event handling.
[paraslash.git] / mood.c
diff --git a/mood.c b/mood.c
index a8d87cde122c9bc03d6cab301695fe97bf2896e8..9074581c6c8d40741a99c3c1772716381e03f2a4 100644 (file)
--- a/mood.c
+++ b/mood.c
@@ -1047,10 +1047,14 @@ int reload_current_mood(void)
        int ret;
        char *mood_name;
 
+       PARA_NOTICE_LOG("reloading current mood\n");
        if (!current_mood)
                return 1;
        mood_name = para_strdup(current_mood->name);
        close_current_mood();
+       ret = clear_score_table();
+       if (ret < 0)
+               return ret;
        ret = change_current_mood(mood_name);
        free(mood_name);
        return ret;
@@ -1060,10 +1064,22 @@ int moods_event_handler(enum afs_events event, struct para_buffer *pb,
                void *data)
 {
        switch(event) {
+       /*
+        * The three blob events might change the set of admissible files,
+        * so we must reload the score list.
+        */
+       case BLOB_RENAME:
+       case BLOB_REMOVE:
+       case BLOB_ADD:
+               if (data == moods_table || data == playlists_table)
+                       return 1; /* no reload necessary for these */
+               return reload_current_mood();
+       /* these also require reload of the score table */
        case ATTRIBUTE_ADD:
        case ATTRIBUTE_REMOVE:
        case ATTRIBUTE_RENAME:
                return reload_current_mood();
+       /* changes to the aft only require to re-examine the audio file */
        case AFSI_CHANGE: {
                struct afsi_change_event_data *aced = data;
                return mood_update_audio_file(aced->aft_row, aced->old_afsi);