Browse Source

review & forgotten fixes from other PR

Simon Frei 7 years ago
parent
commit
81bd428b25

+ 1 - 0
gui/default/assets/lang/lang-en.json

@@ -94,6 +94,7 @@
    "Error": "Error",
    "External File Versioning": "External File Versioning",
    "Failed Items": "Failed Items",
+   "Failed to load ignore patterns": "Failed to load ignore patterns",
    "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.",
    "File Pull Order": "File Pull Order",

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

@@ -2,7 +2,7 @@ angular.module('syncthing.core')
     .config(function($locationProvider) {
         $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';
 
         // private/helper definitions
@@ -715,7 +715,6 @@ angular.module('syncthing.core')
             $http.get(urlbase + "/events/disk?limit=25").success(function (data) {
                 data = data.reverse();
                 $scope.globalChangeEvents = data;
-
                 console.log("refreshGlobalChanges", data);
             }).error($scope.emitHTTPError);
         }, 2500);
@@ -1580,15 +1579,17 @@ angular.module('syncthing.core')
             }
             $scope.currentFolder.externalCommand = $scope.currentFolder.externalCommand || "";
 
-            $('#folder-ignores textarea').val("");
+            $('#folder-ignores textarea').val($translate.instant("Loading..."));
             $('#folder-ignores textarea').attr('disabled', 'disabled');
             $http.get(urlbase + '/db/ignores?folder=' + encodeURIComponent($scope.currentFolder.id))
                 .success(function (data) {
                     $scope.currentFolder.ignores = data.ignore || [];
                     $('#folder-ignores textarea').val($scope.currentFolder.ignores.join('\n'));
-                })
-                .then(function () {
                     $('#folder-ignores textarea').removeAttr('disabled');
+                })
+                .error(function (err) {
+                    $('#folder-ignores textarea').val($translate.instant("Failed to load ignore patterns."));
+                    $scope.emitHTTPError(err);
                 });
 
             $scope.editFolderModal();
@@ -1711,7 +1712,6 @@ angular.module('syncthing.core')
                     });
                 }
             });
-
         };
 
         $scope.dismissFolderRejection = function (folder, device) {

+ 2 - 2
lib/config/config_test.go

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

+ 7 - 7
lib/config/folderconfiguration.go

@@ -18,9 +18,9 @@ import (
 )
 
 var (
-	errPathNotDirectory = errors.New("folder path not a directory")
-	errPathMissing      = errors.New("folder path missing")
-	errMarkerMissing    = errors.New("folder marker missing")
+	ErrPathNotDirectory = errors.New("folder path not a directory")
+	ErrPathMissing      = errors.New("folder path missing")
+	ErrMarkerMissing    = errors.New("folder marker missing")
 )
 
 const DefaultMarkerName = ".stfolder"
@@ -113,7 +113,7 @@ func (f FolderConfiguration) Versioner() versioner.Versioner {
 }
 
 func (f *FolderConfiguration) CreateMarker() error {
-	if err := f.CheckPath(); err != errMarkerMissing {
+	if err := f.CheckPath(); err != ErrMarkerMissing {
 		return err
 	}
 	if f.MarkerName != DefaultMarkerName {
@@ -151,7 +151,7 @@ func (f *FolderConfiguration) CheckPath() error {
 		if !fs.IsNotExist(err) {
 			return err
 		}
-		return errPathMissing
+		return ErrPathMissing
 	}
 
 	// 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"
 	// in the error check above, and we don't even get to here.
 	if !fi.IsDir() && !fi.IsSymlink() {
-		return errPathNotDirectory
+		return ErrPathNotDirectory
 	}
 
 	_, err = f.Filesystem().Stat(f.MarkerName)
@@ -169,7 +169,7 @@ func (f *FolderConfiguration) CheckPath() error {
 		if !fs.IsNotExist(err) {
 			return err
 		}
-		return errMarkerMissing
+		return ErrMarkerMissing
 	}
 
 	return nil

+ 2 - 1
lib/model/model.go

@@ -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
 	}