Fixed updater behaviour when download fails

implemented UpdateTracker method
This commit is contained in:
2018-11-02 14:31:13 +01:00
parent 5e05b68496
commit b613c36cdc

View File

@@ -248,11 +248,11 @@ namespace RothenburgAR.Updater
return; return;
} }
//TODO unzip
var type = http.Request.GetResponseHeader("Content-Type"); var type = http.Request.GetResponseHeader("Content-Type");
File.WriteAllBytes(filepath, http.Download.data); File.WriteAllBytes(filepath, http.Download.data);
Debug.Log(string.Format("{1}-DONE with {0}", url, Time.realtimeSinceStartup)); 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) private void UpdateTracker(ExhibitionVersion exhibition)
{ {
//TODO implement UpdateTracker //TODO test UpdateTracker
throw new NotImplementedException(); 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() 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. // 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) if (downloadEndedTime > DateTime.Now)
{ {