ソースを参照

gui: Fix folder path validation (fixes #7379) (#7585)

Simon Frei 4 年 前
コミット
031b91c0ed
1 ファイル変更6 行追加3 行削除
  1. 6 3
      gui/default/syncthing/core/pathIsSubDirDirective.js

+ 6 - 3
gui/default/syncthing/core/pathIsSubDirDirective.js

@@ -3,7 +3,7 @@ angular.module('syncthing.core')
         return {
             require: 'ngModel',
             link: function (scope, elm, attrs, ctrl) {
-                ctrl.$parsers.unshift(function (viewValue) {
+                ctrl.$validators.folderPathErrors = function (viewValue) {
                     // This function checks whether ydir is a subdirectory of xdir,
                     // e.g. it would return true if xdir = "/home/a", ydir = "/home/a/b".
                     function isSubDir(xdir, ydir) {
@@ -25,6 +25,9 @@ angular.module('syncthing.core')
                     scope.folderPathErrors.otherID = "";
                     scope.folderPathErrors.otherLabel = "";
                     for (var folderID in scope.folders) {
+                        if (folderID === scope.currentFolder.id) {
+                            continue;
+                        }
                         if (isSubDir(scope.folders[folderID].path, viewValue)) {
                             scope.folderPathErrors.otherID = folderID;
                             scope.folderPathErrors.otherLabel = scope.folders[folderID].label;
@@ -39,8 +42,8 @@ angular.module('syncthing.core')
                             break;
                         }
                     }
-                    return viewValue;
-                });
+                    return true;
+                };
             }
         };
     });