From b613c36cdc68682ae38e7d52bed68efcc276a4ae Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 2 Nov 2018 14:31:13 +0100 Subject: [PATCH] Fixed updater behaviour when download fails implemented UpdateTracker method --- .../Scripts/Updater/UpdaterBehaviour.cs | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/Assets/RothenburgAR/Scripts/Updater/UpdaterBehaviour.cs b/Assets/RothenburgAR/Scripts/Updater/UpdaterBehaviour.cs index c784a2c..41cc052 100644 --- a/Assets/RothenburgAR/Scripts/Updater/UpdaterBehaviour.cs +++ b/Assets/RothenburgAR/Scripts/Updater/UpdaterBehaviour.cs @@ -248,11 +248,11 @@ namespace RothenburgAR.Updater return; } + //TODO unzip var type = http.Request.GetResponseHeader("Content-Type"); File.WriteAllBytes(filepath, http.Download.data); Debug.Log(string.Format("{1}-DONE with {0}", url, Time.realtimeSinceStartup)); - //TODO unzip }; } } @@ -282,8 +282,29 @@ namespace RothenburgAR.Updater private void UpdateTracker(ExhibitionVersion exhibition) { - //TODO implement UpdateTracker - throw new NotImplementedException(); + //TODO test UpdateTracker + var path = PathHelper.CombinePaths(PathHelper.ExhibitionPath, exhibition.Id); + var url = exhibition.Tracker.UpdateUrl; + var http = new HttpRequest(url, HttpVerb.GET).Send(); + httpHandlers.Add(http); + + http.Operation.completed += ar => + { + if (CheckNetworkErrors(http)) + { + return; + } + + if (!Directory.Exists(path)) + { + Directory.CreateDirectory(path); + } + + //TODO unzip, should be tracker.xml and tracker.dat files + var type = http.Request.GetResponseHeader("Content-Type"); + File.WriteAllBytes(Path.Combine(path, "tracker.zip"), http.Download.data); + Debug.Log(string.Format("{1}-DONE with {0}", url, Time.realtimeSinceStartup)); + }; } public void LoadMainScene() @@ -316,7 +337,7 @@ namespace RothenburgAR.Updater } // Continue to Main Scene after all downloads are done and this.afterDownloadWaitTime seconds have passed without any new downloads triggering. - if (httpHandlers.All(h => h.IsDone)) + if (httpHandlers.All(h => h.IsDone) && !UpdateFailedDialog.activeInHierarchy) { if (downloadEndedTime > DateTime.Now) {