Skip to content

Commit

Permalink
Stop assuming task.UpdateConditions is not null
Browse files Browse the repository at this point in the history
  • Loading branch information
synhershko committed Jul 3, 2012
1 parent 6b6a531 commit ed2b72c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
5 changes: 1 addition & 4 deletions src/NAppUpdate.Framework/FeedReaders/AppcastReader.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System;
using System.Xml;
using System.Collections.Generic;

using NAppUpdate.Framework.FeedReaders;
using NAppUpdate.Framework.Tasks;
using NAppUpdate.Framework.Conditions;

Expand All @@ -26,11 +23,11 @@ public IList<IUpdateTask> Read(string feed)
{
FileUpdateTask task = new FileUpdateTask();
task.Description = n["description"].InnerText;
//task.UpdateTo = n["enclosure"].Attributes["url"].Value;
task.UpdateTo = n["enclosure"].Attributes["url"].Value;

FileVersionCondition cnd = new FileVersionCondition();
cnd.Version = n["appcast:version"].InnerText;
if (task.UpdateConditions == null) task.UpdateConditions = new BooleanCondition();
task.UpdateConditions.AddCondition(cnd, BooleanCondition.ConditionType.AND);

ret.Add(task);
Expand Down
12 changes: 8 additions & 4 deletions src/NAppUpdate.Framework/FeedReaders/NauXmlFeedReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,14 @@ public IList<IUpdateTask> Read(string feed)
IUpdateCondition conditionObject = ReadCondition(node["Conditions"]);
if (conditionObject != null)
{
if (conditionObject is BooleanCondition)
task.UpdateConditions = conditionObject as BooleanCondition;
else
task.UpdateConditions.AddCondition(conditionObject);
var boolCond = conditionObject as BooleanCondition;
if (boolCond != null)
task.UpdateConditions = boolCond;
else
{
if (task.UpdateConditions == null) task.UpdateConditions = new BooleanCondition();
task.UpdateConditions.AddCondition(conditionObject);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/NAppUpdate.Framework/UpdateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private bool CheckForUpdates(IUpdateSource source, Action<bool> callback)
return false;
}

if (t.UpdateConditions.IsMet(t)) // Only execute if all conditions are met
if (t.UpdateConditions == null || t.UpdateConditions.IsMet(t)) // Only execute if all conditions are met
UpdatesToApply.Add(t);
}
}
Expand Down

0 comments on commit ed2b72c

Please sign in to comment.