From d7e21127d766bde7b0d8d0d614eafcb771dad9ae Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sat, 28 May 2011 18:33:26 +0100 Subject: [PATCH] controller: download new version number check to memory instead of a file --- SparkleShare/SparkleController.cs | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/SparkleShare/SparkleController.cs b/SparkleShare/SparkleController.cs index 3ced2aaa..d2f4f839 100644 --- a/SparkleShare/SparkleController.cs +++ b/SparkleShare/SparkleController.cs @@ -1071,32 +1071,23 @@ namespace SparkleShare { public void CheckForNewVersion () { - string new_version_file_path = System.IO.Path.Combine (SparklePaths.SparkleTmpPath, - "version"); - - if (File.Exists (new_version_file_path)) - File.Delete (new_version_file_path); - WebClient web_client = new WebClient (); Uri uri = new Uri ("http://www.sparkleshare.org/version"); - web_client.DownloadFileCompleted += delegate { + web_client.DownloadStringCompleted += delegate (object o, DownloadStringCompletedEventArgs args) { + string new_version = args.Result.Trim (); - if (new FileInfo (new_version_file_path).Length > 0) { - StreamReader reader = new StreamReader (new_version_file_path); - string downloaded_version_number = reader.ReadToEnd ().Trim (); + if (Defines.VERSION.Equals (new_version)) { + if (VersionUpToDate != null) + VersionUpToDate (); - if (Defines.VERSION.Equals (downloaded_version_number)) { - if (VersionUpToDate != null) - VersionUpToDate (); - } else { - if (NewVersionAvailable != null) - NewVersionAvailable (downloaded_version_number); - } + } else { + if (NewVersionAvailable != null) + NewVersionAvailable (new_version); } }; - web_client.DownloadFileAsync (uri, new_version_file_path); + web_client.DownloadStringAsync (uri); } }