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
This commit is contained in:
Jakob Borg 2017-04-24 08:51:08 +09:00
parent 914b09fd1f
commit 7f5e236dd7

View File

@ -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();
}
});
};