Skip to content

Commit 0568f98

Browse files
committed
Fixes for auto update returning incorrect response. Fix for possible infinite loop situation.
1 parent e8685be commit 0568f98

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

AutoUpdate/autoupdate.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ var AutoUpdate = function (params) {
4545
self.getLastModInfo(self.fileURLCheck, function(lastModInfo) {
4646
// This anonymous function is called when the getLastModInfo function completes
4747
// Now compare the last mod info to see if it needs reloading
48-
if ((lastModifiedToken != "") && ((self.isDateMode && lastModInfo > lastModifiedToken) || (!self.isDateMode && lastModInfo != lastModifiedToken))) {
48+
if ((lastModifiedToken != "") && lastModInfo != null && ((self.isDateMode && lastModInfo > lastModifiedToken) || (!self.isDateMode && lastModInfo != lastModifiedToken))) {
4949
// GUI needs to be reloaded
5050
CF.log("UPDATE AVAILABLE!");
5151
self.lastModInfo = lastModInfo;
@@ -75,14 +75,17 @@ var AutoUpdate = function (params) {
7575
// The HTTP response must issue Last-Modified or Etag headers for this to work (not all servers will do this!)
7676
self.getLastModInfo = function (fileURL, callback) {
7777
if (!fileURL || !callback) {
78+
CF.log("AUTO UPDATE ERROR: URL and callback function are required.");
7879
callback(null);
7980
}
8081
CF.request(fileURL, self.requestMethod, null, function(status, headers) {
8182
if (status == "405") {
8283
// Try again, using GET method instead, and use GET for all future checks
8384
CF.log(self.requestMethod + " mode not supported by server hosting the GUI.");
84-
self.requestMethod = "GET";
85-
self.getLastModInfo(fileURL, callback);
85+
if (self.requestMethod != "GET") {
86+
self.requestMethod = "GET";
87+
self.getLastModInfo(fileURL, callback);
88+
}
8689
} else if (status != "200") {
8790
CF.log("AUTO UPDATE ERROR: GUI File URL returned HTTP Code " + status);
8891
callback(null);

0 commit comments

Comments
 (0)