From 2e69f5dac6ff09a4b0afb4722188c7a95ad351c5 Mon Sep 17 00:00:00 2001 From: whatdoineed2do/Ray Date: Sat, 21 Nov 2020 14:01:39 +0000 Subject: [PATCH] [rss] defer playlistitems purge til ready to update with new rss Current impl fetches pl, purge pl items, fetch RSS, inserts entries. If the RSS fetch fails (remote server is temporary unreachable) the playlistitems for that RSS are all dropped. This has a side effect that RSS playlists cannot be determined from tracks (see issue #1126) and thus cannot be deleted. Simple fix to defer playlist item purge to the point that the RSS fetch is ok and before the inserts --- src/library/rssscanner.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/library/rssscanner.c b/src/library/rssscanner.c index 150eeb0c..8f035c7e 100644 --- a/src/library/rssscanner.c +++ b/src/library/rssscanner.c @@ -204,7 +204,6 @@ playlist_fetch(bool *is_new, const char *path) pli = db_pl_fetch_bypath(path); if (pli) { - db_pl_clear_items(pli->id); *is_new = false; return pli; } @@ -453,6 +452,7 @@ rss_save(struct playlist_info *pli, int *count, enum rss_scan_type scan_type) // Walk through the xml, saving each item *count = 0; db_transaction_begin(); + db_pl_clear_items(pli->id); while ((ret = rss_xml_parse_item(&ri, xml, &ptr)) == 0 && (*count < pli->query_limit)) { if (library_is_exiting()) @@ -509,7 +509,7 @@ rss_scan(const char *path, enum rss_scan_type scan_type) int count; int ret; - // Fetches or creates playlist, clears playlistitems + // Fetches or creates playlist pli = playlist_fetch(&pl_is_new, path); if (!pli) return -1; @@ -517,6 +517,8 @@ rss_scan(const char *path, enum rss_scan_type scan_type) // Retrieves the RSS and reads the feed, saving each item as a track, and also // adds the relationship to playlistitems. The pli will also be updated with // metadata from the RSS. + // + // playlistitems are only cleared if we are ready to add entries ret = rss_save(pli, &count, scan_type); if (ret < 0) goto error; @@ -612,7 +614,6 @@ static int rss_fullscan(void) { DPRINTF(E_LOG, L_LIB, "RSS feeds removed during full-rescan\n"); - return LIBRARY_OK; }