Fixes for unstable internet access
This commit is contained in:
@@ -76,8 +76,7 @@ namespace RothenburgAR.Updater
|
||||
Debug.Log(string.Format("{1}-DONE with {0}", ApiInfo.VersionCheckEndpoint, Time.realtimeSinceStartup));
|
||||
|
||||
var answer = VersionAnswer;
|
||||
|
||||
if (VersionAnswer.Data.TrueForAll(d => d.Meta.Status == VersionStatus.ok && d.Tracker.Status == VersionStatus.ok))
|
||||
if (VersionAnswer != null && VersionAnswer.Data.TrueForAll(d => d.Meta.Status == VersionStatus.ok && d.Tracker.Status == VersionStatus.ok))
|
||||
{
|
||||
// no updates required, continue to app
|
||||
LoadMainScene();
|
||||
@@ -141,9 +140,34 @@ namespace RothenburgAR.Updater
|
||||
* ...
|
||||
*/
|
||||
|
||||
/*
|
||||
Update-Konsistenz
|
||||
- was aktuell noch schlecht ist:
|
||||
- metadaten werden erfolgreich heruntergeladen, medien nicht -> nach reset ist exhibition ok und die medien werden nicht nochmal geprüft
|
||||
- parallele downloads evtl schlecht bei brüchiger verbindung
|
||||
- race condition beim azeigen von "ist fertig"
|
||||
|
||||
- Update in einem cache halten, danach prüfen und wegschreiben (per exhibition sollte ok sein)
|
||||
was passieren kann:
|
||||
httpRequest bricht ab mit NetworkError:true
|
||||
httpRequest bricht ab mit HttpError:true
|
||||
httpRequest gibt leeren body zurück
|
||||
|
||||
- In 2 Schritte aufteilen:
|
||||
1: Metadaten, die dann parsen und somit prüfen
|
||||
2: Medien&Tracker, die dann auf 0-byte-länge prüfen
|
||||
somit kann man die kleinen Daten auf einmal machen und die großen bei bedarf einzeln neu versuchen
|
||||
|
||||
- bei Fehler noch 2 weitere male probieren
|
||||
|
||||
- progressbar vllt ersetzen durch durchlaufdingens?
|
||||
*/
|
||||
|
||||
UpdateConfirmationDialog.SetActive(false);
|
||||
UpdateFailedDialog.SetActive(false);
|
||||
this.downloadingMedia.Clear();
|
||||
this.httpHandlers.ForEach(h => h.Request.Abort());
|
||||
this.httpHandlers.Clear();
|
||||
|
||||
if (VersionAnswer == null)
|
||||
{
|
||||
@@ -210,9 +234,18 @@ namespace RothenburgAR.Updater
|
||||
Debug.Log(string.Format("{1}-DONE with {0}", url, Time.realtimeSinceStartup));
|
||||
|
||||
var exhibits = JsonConvert.DeserializeObject<List<ApiExhibit>>(http.Download.text);
|
||||
foreach (var exhibit in exhibits)
|
||||
if (exhibits == null)
|
||||
{
|
||||
UpdateMedia(exhibit, currentHandlers);
|
||||
Debug.LogError(string.Format("Exhibit could not be parsed from Json:\nurl: {0}\njson: {1}", url, http.Download.text));
|
||||
ResetUpdateOnError();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var exhibit in exhibits)
|
||||
{
|
||||
UpdateMedia(exhibit, currentHandlers);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -267,6 +300,13 @@ namespace RothenburgAR.Updater
|
||||
// do nothing if unchanged
|
||||
if (http.Request.responseCode == 304) return;
|
||||
|
||||
if (http.Download.data.Length == 0)
|
||||
{
|
||||
Debug.LogError(string.Format("Downloaded Media is 0 bytes long:\nurl: {0}", url));
|
||||
ResetUpdateOnError();
|
||||
return;
|
||||
}
|
||||
|
||||
// gzipped files are un-gzipped automagically
|
||||
File.WriteAllBytes(filepath, http.Download.data);
|
||||
|
||||
@@ -375,6 +415,13 @@ namespace RothenburgAR.Updater
|
||||
// do nothing if unchanged
|
||||
if (http.Request.responseCode == 304) return;
|
||||
|
||||
if (http.Download.data.Length == 0)
|
||||
{
|
||||
Debug.LogError(string.Format("Downloaded Subfile is 0 bytes long:\nurl: {0}", url));
|
||||
ResetUpdateOnError();
|
||||
return;
|
||||
}
|
||||
|
||||
// gzipped files are un-gzipped automagically
|
||||
File.WriteAllBytes(filepath, http.Download.data);
|
||||
|
||||
@@ -392,8 +439,7 @@ namespace RothenburgAR.Updater
|
||||
http.Request.isHttpError,
|
||||
http.Request.responseCode));
|
||||
|
||||
UpdateDialog.SetActive(true);
|
||||
UpdateFailedDialog.SetActive(true);
|
||||
ResetUpdateOnError();
|
||||
|
||||
//TODO decide on level of detail for user notification
|
||||
//var all = UpdateFailedDialog.GetComponentsInChildren<TextMeshProUGUI>().ToList();
|
||||
@@ -405,6 +451,14 @@ namespace RothenburgAR.Updater
|
||||
return false;
|
||||
}
|
||||
|
||||
private void ResetUpdateOnError()
|
||||
{
|
||||
UpdateDialog.SetActive(true);
|
||||
UpdateFailedDialog.SetActive(true);
|
||||
|
||||
this.httpHandlers.ForEach(h => h.Request.Abort());
|
||||
}
|
||||
|
||||
public void LoadMainScene()
|
||||
{
|
||||
Debug.Log("Loading mainScene");
|
||||
|
||||
Reference in New Issue
Block a user