[banshee] Feed: Avoid loop when podcast has date values in the future (bgo#706173)



commit 78ff9e54d4dee24dacc36a172b52b5917f8d20b8
Author: Bertrand Lorentz <bertrand lorentz gmail com>
Date:   Sat Aug 17 14:26:50 2013 +0200

    Feed: Avoid loop when podcast has date values in the future (bgo#706173)
    
    CheckForItemsToDownload needs to save the feed, which in turn would call
    CheckForItemsToDownload. This could cause an infinite loop if both the
    feed LastBuildDate and an item's PubDate were set in the future.
    
    To avoid that, add a new Save method with a parameter to avoid calling
    CheckForItemsToDownload, and use that method in CheckForItemsToDownload.
    
    This is not a great API (with 2 bool parameters), but it's the best I
    could come up with to avoid breaking existing API or risking unwanted
    side-effects.

 src/Libraries/Migo/Migo.Syndication/Feed.cs |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/src/Libraries/Migo/Migo.Syndication/Feed.cs b/src/Libraries/Migo/Migo.Syndication/Feed.cs
index 827d76d..1396f5a 100644
--- a/src/Libraries/Migo/Migo.Syndication/Feed.cs
+++ b/src/Libraries/Migo/Migo.Syndication/Feed.cs
@@ -560,10 +560,15 @@ namespace Migo.Syndication
 
         public void Save (bool notify)
         {
+            Save (notify, true);
+        }
+
+        public void Save (bool notify, bool download_items)
+        {
             Provider.Save (this);
             CheckForItemsToArchive ();
 
-            if (LastBuildDate > LastAutoDownload) {
+            if (download_items && (LastBuildDate > LastAutoDownload)) {
                 CheckForItemsToDownload ();
             }
 
@@ -609,7 +614,8 @@ namespace Migo.Syndication
 
             if (any) {
                 LastAutoDownload = DateTime.Now;
-                Save ();
+                // We don't want Save to call CheckForItemsToDownload again
+                Save (true, false);
             }
         }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]