浏览代码

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 10 年之前
父节点
当前提交
2bed62dd9e
共有 3 个文件被更改,包括 7 次插入10 次删除
  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) {
     $httpProvider.interceptors.push(function xHeadersResponseInterceptor() {
-        var guiVersion = null;
         var deviceId = null;
 
         return {
@@ -38,14 +37,6 @@ syncthing.config(function ($httpProvider, $translateProvider, LocaleServiceProvi
                     return response;
                 }
 
-                responseVersion = headers['x-syncthing-version'];
-
-                if (!guiVersion) {
-                    guiVersion = responseVersion;
-                } else if (guiVersion != responseVersion) {
-                    document.location.reload(true);
-                }
-
                 if (!deviceId) {
                     deviceId = headers['x-syncthing-id'];
                     if (deviceId) {

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

@@ -89,6 +89,12 @@ angular.module('syncthing.core')
             refreshFolderStats();
 
             $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;
             }).error($scope.emitHTTPError);
 

文件差异内容过多而无法显示
+ 1 - 1
lib/auto/gui.files.go


部分文件因为文件数量过多而无法显示