Explorar o código

Don't trust response header (fixes #2186)

Either Angular or the browser sometimes returns cached repsonse header,
causing a flap between requests that return the new version and requests
that return the old one. Here, instead, we trust the actual data
returned by the uncached /rest/system/version call.
Jakob Borg %!s(int64=10) %!d(string=hai) anos
pai
achega
2bed62dd9e
Modificáronse 3 ficheiros con 7 adicións e 10 borrados
  1. 0 9
      gui/syncthing/app.js
  2. 6 0
      gui/syncthing/core/syncthingController.js
  3. 1 1
      lib/auto/gui.files.go

+ 0 - 9
gui/syncthing/app.js

@@ -24,7 +24,6 @@ var urlbase = 'rest';
 
 
 syncthing.config(function ($httpProvider, $translateProvider, LocaleServiceProvider) {
 syncthing.config(function ($httpProvider, $translateProvider, LocaleServiceProvider) {
     $httpProvider.interceptors.push(function xHeadersResponseInterceptor() {
     $httpProvider.interceptors.push(function xHeadersResponseInterceptor() {
-        var guiVersion = null;
         var deviceId = null;
         var deviceId = null;
 
 
         return {
         return {
@@ -38,14 +37,6 @@ syncthing.config(function ($httpProvider, $translateProvider, LocaleServiceProvi
                     return response;
                     return response;
                 }
                 }
 
 
-                responseVersion = headers['x-syncthing-version'];
-
-                if (!guiVersion) {
-                    guiVersion = responseVersion;
-                } else if (guiVersion != responseVersion) {
-                    document.location.reload(true);
-                }
-
                 if (!deviceId) {
                 if (!deviceId) {
                     deviceId = headers['x-syncthing-id'];
                     deviceId = headers['x-syncthing-id'];
                     if (deviceId) {
                     if (deviceId) {

+ 6 - 0
gui/syncthing/core/syncthingController.js

@@ -89,6 +89,12 @@ angular.module('syncthing.core')
             refreshFolderStats();
             refreshFolderStats();
 
 
             $http.get(urlbase + '/system/version').success(function (data) {
             $http.get(urlbase + '/system/version').success(function (data) {
+                if ($scope.version.version && $scope.version.version != data.version) {
+                    // We already have a version response, but it differs from
+                    // the new one. Reload the full GUI in case it's changed.
+                    document.location.reload(true);
+                }
+
                 $scope.version = data;
                 $scope.version = data;
             }).error($scope.emitHTTPError);
             }).error($scope.emitHTTPError);
 
 

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 1
lib/auto/gui.files.go


Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio