public void ShouldAbortGracefullyOnUnversionedFiles() { var tempFile = Path.GetTempFileName(); File.WriteAllText(tempFile, "foo"); var cnd = new FileVersionCondition { ComparisonType = "is", LocalPath = tempFile, Version = "1.0.0.0" }; Assert.IsTrue(cnd.IsMet(null)); }
public IList<IUpdateTask> Read(string feed) { var doc = new XmlDocument(); doc.LoadXml(feed); XmlNodeList nodeList = doc.SelectNodes("/rss/channel/item"); var updateTasks = new List<IUpdateTask>(); bool foundOneVersion = false; foreach (XmlNode node in nodeList) { var task = new InstallerUpdateTask(); task.Description = node["description"].InnerText.Trim('\n').Replace("\n", "\r\n"); Description = task.Description; string url = node["enclosure"].Attributes["url"].Value; task.UpdateTo = url; Version = node["appcast:version"].InnerText; if (".exe".Equals(Path.GetExtension(url)) || ".msi".Equals(Path.GetExtension(url))) { string fileName = Path.GetFileName(url); task.LocalPath = fileName; //string baseDirectory = Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName); //UpdateManager.Instance.ApplicationPath = Path.Combine(baseDirectory, fileName); var condition = new ApplicationVersionCondition(ApplicationVersion); condition.Attributes.Add("version", Version); task.UpdateConditions.AddCondition(condition, BooleanCondition.ConditionType.AND); task.UpdateConditions.Attributes.Add("version", Version); } else { var condition = new FileVersionCondition(); condition.Version = Version; task.UpdateConditions.AddCondition(condition, BooleanCondition.ConditionType.AND); task.UpdateConditions.Attributes.Add("version", Version); } if (foundOneVersion) { task.DataOnly = true; } foundOneVersion = true; updateTasks.Add(task); } return updateTasks; }
public IList<IUpdateTask> Read(string feed) { XmlDocument doc = new XmlDocument(); doc.LoadXml(feed); XmlNodeList nl = doc.SelectNodes("/rss/channel/item"); List<IUpdateTask> ret = new List<IUpdateTask>(); foreach (XmlNode n in nl) { FileUpdateTask task = new FileUpdateTask(); task.Description = n["description"].InnerText; task.Attributes.Add("remotePath", n["enclosure"].Attributes["url"].Value); FileVersionCondition cnd = new FileVersionCondition(); cnd.Attributes.Add("version", n["appcast:version"].InnerText); task.UpdateConditions.AddCondition(cnd, BooleanCondition.ConditionType.AND); ret.Add(task); } return ret; }