]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
dvr: Remove fanart entries from the list until we process one.
authorE.Smith <31170571+azlm8t@users.noreply.github.com>
Wed, 3 Oct 2018 23:54:45 +0000 (00:54 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 8 Oct 2018 12:01:16 +0000 (14:01 +0200)
We might have entries on our list of pending fanart fetches that
no longer need fetching (user changed config, etc.)  So keep
removing entries from the list until we find ones that need
a fanart fetch.

src/dvr/dvr_db.c
src/dvr/dvr_rec.c

index 02a9174edf1b80ee84b2d590175f6a6975bb678a..bffc2cb66d952703214df45c153693f9a46f8e74 100644 (file)
@@ -815,21 +815,33 @@ dvr_entry_fanart_add_to_prefetch(const dvr_entry_t *de)
 static void
 dvr_entry_fanart_prefetch_cb(void *aux)
 {
+  char *id;
+  dvr_entry_t *de;
+
   lock_assert(&global_lock);
 
   /* Only do one entry, even if list has many since we don't
    * want to overload fanart providers.
+   *
+   * However we may have items on the list that don't need
+   * fanart lookup, so skip over any of this.
    */
-  char *id = string_list_remove_first(dvr_fanart_to_prefetch);
-  if (id) {
-    dvr_entry_t *de = dvr_entry_find_by_uuid(id);
-    if (de && de->de_config && de->de_config->dvr_fetch_artwork) {
+  int done_one = 0;
+  while (!done_one) {
+    id = string_list_remove_first(dvr_fanart_to_prefetch);
+    /* No entries left on list? */
+    if (!id)
+      break;
+
+    de = dvr_entry_find_by_uuid(id);
+    if (dvr_entry_allow_fanart_lookup(de)) {
       tvhinfo(LS_DVR, "Prefetching artwork for %s \"%s\"", id, lang_str_get(de->de_title, NULL));
       dvr_spawn_fetch_artwork(de);
+      done_one = 1;
     }
 
     free(id);
-  }
+  } /* !done_one */
 
   // Re-arm timer with a slight random factor to avoid queries at same
   // time every hour.
index 54c861a43cea60d701577d8edf6b65a50a333a53..d694f368edf9899e5fbb6eeb92483f6b5fe2cc9c 100644 (file)
@@ -66,7 +66,7 @@ dvr_spawn_fetch_artwork(dvr_entry_t *de)
   char ubuf[UUID_HEX_SIZE];
 
   if (!dvr_entry_allow_fanart_lookup(de))
-      return;
+    return;
 
   snprintf(buf, sizeof buf, "tvhmeta --uuid %s %s",
            idnode_uuid_as_str(&de->de_id, ubuf),