review & forgotten fixes from other PR

This commit is contained in:
Simon Frei 2018-03-18 01:42:31 +01:00 committed by Audrius Butkevicius
parent ae74ac8329
commit 81bd428b25
5 changed files with 18 additions and 16 deletions

View File

@ -94,6 +94,7 @@
"Error": "Error", "Error": "Error",
"External File Versioning": "External File Versioning", "External File Versioning": "External File Versioning",
"Failed Items": "Failed Items", "Failed Items": "Failed Items",
"Failed to load ignore patterns": "Failed to load ignore patterns",
"Failed to setup, retrying": "Failed to setup, retrying", "Failed to setup, retrying": "Failed to setup, retrying",
"Failure to connect to IPv6 servers is expected if there is no IPv6 connectivity.": "Failure to connect to IPv6 servers is expected if there is no IPv6 connectivity.", "Failure to connect to IPv6 servers is expected if there is no IPv6 connectivity.": "Failure to connect to IPv6 servers is expected if there is no IPv6 connectivity.",
"File Pull Order": "File Pull Order", "File Pull Order": "File Pull Order",

View File

@ -2,7 +2,7 @@ angular.module('syncthing.core')
.config(function($locationProvider) { .config(function($locationProvider) {
$locationProvider.html5Mode({enabled: true, requireBase: false}).hashPrefix('!'); $locationProvider.html5Mode({enabled: true, requireBase: false}).hashPrefix('!');
}) })
.controller('SyncthingController', function ($scope, $http, $location, LocaleService, Events, $filter, $q, $compile, $timeout, $rootScope) { .controller('SyncthingController', function ($scope, $http, $location, LocaleService, Events, $filter, $q, $compile, $timeout, $rootScope, $translate) {
'use strict'; 'use strict';
// private/helper definitions // private/helper definitions
@ -715,7 +715,6 @@ angular.module('syncthing.core')
$http.get(urlbase + "/events/disk?limit=25").success(function (data) { $http.get(urlbase + "/events/disk?limit=25").success(function (data) {
data = data.reverse(); data = data.reverse();
$scope.globalChangeEvents = data; $scope.globalChangeEvents = data;
console.log("refreshGlobalChanges", data); console.log("refreshGlobalChanges", data);
}).error($scope.emitHTTPError); }).error($scope.emitHTTPError);
}, 2500); }, 2500);
@ -1580,15 +1579,17 @@ angular.module('syncthing.core')
} }
$scope.currentFolder.externalCommand = $scope.currentFolder.externalCommand || ""; $scope.currentFolder.externalCommand = $scope.currentFolder.externalCommand || "";
$('#folder-ignores textarea').val(""); $('#folder-ignores textarea').val($translate.instant("Loading..."));
$('#folder-ignores textarea').attr('disabled', 'disabled'); $('#folder-ignores textarea').attr('disabled', 'disabled');
$http.get(urlbase + '/db/ignores?folder=' + encodeURIComponent($scope.currentFolder.id)) $http.get(urlbase + '/db/ignores?folder=' + encodeURIComponent($scope.currentFolder.id))
.success(function (data) { .success(function (data) {
$scope.currentFolder.ignores = data.ignore || []; $scope.currentFolder.ignores = data.ignore || [];
$('#folder-ignores textarea').val($scope.currentFolder.ignores.join('\n')); $('#folder-ignores textarea').val($scope.currentFolder.ignores.join('\n'));
})
.then(function () {
$('#folder-ignores textarea').removeAttr('disabled'); $('#folder-ignores textarea').removeAttr('disabled');
})
.error(function (err) {
$('#folder-ignores textarea').val($translate.instant("Failed to load ignore patterns."));
$scope.emitHTTPError(err);
}); });
$scope.editFolderModal(); $scope.editFolderModal();
@ -1711,7 +1712,6 @@ angular.module('syncthing.core')
}); });
} }
}); });
}; };
$scope.dismissFolderRejection = function (folder, device) { $scope.dismissFolderRejection = function (folder, device) {

View File

@ -436,11 +436,11 @@ func TestFolderCheckPath(t *testing.T) {
}{ }{
{ {
path: "", path: "",
err: errMarkerMissing, err: ErrMarkerMissing,
}, },
{ {
path: "does not exist", path: "does not exist",
err: errPathMissing, err: ErrPathMissing,
}, },
{ {
path: "dir", path: "dir",

View File

@ -18,9 +18,9 @@ import (
) )
var ( var (
errPathNotDirectory = errors.New("folder path not a directory") ErrPathNotDirectory = errors.New("folder path not a directory")
errPathMissing = errors.New("folder path missing") ErrPathMissing = errors.New("folder path missing")
errMarkerMissing = errors.New("folder marker missing") ErrMarkerMissing = errors.New("folder marker missing")
) )
const DefaultMarkerName = ".stfolder" const DefaultMarkerName = ".stfolder"
@ -113,7 +113,7 @@ func (f FolderConfiguration) Versioner() versioner.Versioner {
} }
func (f *FolderConfiguration) CreateMarker() error { func (f *FolderConfiguration) CreateMarker() error {
if err := f.CheckPath(); err != errMarkerMissing { if err := f.CheckPath(); err != ErrMarkerMissing {
return err return err
} }
if f.MarkerName != DefaultMarkerName { if f.MarkerName != DefaultMarkerName {
@ -151,7 +151,7 @@ func (f *FolderConfiguration) CheckPath() error {
if !fs.IsNotExist(err) { if !fs.IsNotExist(err) {
return err return err
} }
return errPathMissing return ErrPathMissing
} }
// Users might have the root directory as a symlink or reparse point. // Users might have the root directory as a symlink or reparse point.
@ -161,7 +161,7 @@ func (f *FolderConfiguration) CheckPath() error {
// Stat ends up calling stat on C:\dir\file\ which, fails with "is not a directory" // Stat ends up calling stat on C:\dir\file\ which, fails with "is not a directory"
// in the error check above, and we don't even get to here. // in the error check above, and we don't even get to here.
if !fi.IsDir() && !fi.IsSymlink() { if !fi.IsDir() && !fi.IsSymlink() {
return errPathNotDirectory return ErrPathNotDirectory
} }
_, err = f.Filesystem().Stat(f.MarkerName) _, err = f.Filesystem().Stat(f.MarkerName)
@ -169,7 +169,7 @@ func (f *FolderConfiguration) CheckPath() error {
if !fs.IsNotExist(err) { if !fs.IsNotExist(err) {
return err return err
} }
return errMarkerMissing return ErrMarkerMissing
} }
return nil return nil

View File

@ -1428,7 +1428,8 @@ func (m *Model) GetIgnores(folder string) ([]string, []string, error) {
} }
} }
if err := cfg.CheckPath(); err != nil { // On creation a new folder with ignore patterns validly has no marker yet.
if err := cfg.CheckPath(); err != nil && err != config.ErrMarkerMissing {
return nil, nil, err return nil, nil, err
} }