From 7f5e236dd7dc08788747727585fd5ef7c2862c6e Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Mon, 24 Apr 2017 08:51:08 +0900 Subject: [PATCH] gui: Wait for config commit before setting ignores (ref #4095) Given the saveConfig() is async, it might not have happened before we try to save the ignores and unpause. Likewise must wait for saving ignores before unpausing or the scan might start before ignores are on disk. Javsacript <3 --- .../syncthing/core/syncthingController.js | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/gui/default/syncthing/core/syncthingController.js b/gui/default/syncthing/core/syncthingController.js index 8093252e..e2db0fe9 100755 --- a/gui/default/syncthing/core/syncthingController.js +++ b/gui/default/syncthing/core/syncthingController.js @@ -1042,7 +1042,7 @@ angular.module('syncthing.core') $('#settings').modal(); }; - $scope.saveConfig = function () { + $scope.saveConfig = function (cb) { var cfg = JSON.stringify($scope.config); var opts = { headers: { @@ -1052,6 +1052,9 @@ angular.module('syncthing.core') $http.post(urlbase + '/system/config', cfg, opts).success(function () { $http.get(urlbase + '/system/config/insync').success(function (data) { $scope.configInSync = data.configInSync; + if (cb) { + cb(); + } }); }).error($scope.emitHTTPError); }; @@ -1512,12 +1515,13 @@ angular.module('syncthing.core') $scope.folders[folderCfg.id] = folderCfg; $scope.config.folders = folderList($scope.folders); - $scope.saveConfig(); - - if (!$scope.editingExisting && ignores) { - $scope.saveIgnores(); - $scope.setFolderPause(folderCfg.id, false); - }; + $scope.saveConfig(function () { + if (!$scope.editingExisting && ignores) { + $scope.saveIgnores(function () { + $scope.setFolderPause(folderCfg.id, false); + }); + } + }); }; $scope.dismissFolderRejection = function (folder, device) { @@ -1605,9 +1609,13 @@ angular.module('syncthing.core') }; - $scope.saveIgnores = function () { + $scope.saveIgnores = function (cb) { $http.post(urlbase + '/db/ignores?folder=' + encodeURIComponent($scope.currentFolder.id), { ignore: $('#editIgnores textarea').val().split('\n') + }).success(function () { + if (cb) { + cb(); + } }); };