a small fix and a few additional comments for PR 4962 (#5077)

This commit is contained in:
gpatel-fr
2023-12-23 14:26:56 +01:00
committed by GitHub
parent 396f7dfebe
commit 8fe4c49ce6
2 changed files with 6 additions and 3 deletions
@@ -6,6 +6,8 @@ backupApp.directive('parseFilterType', function(AppUtils, SystemInfo) {
ctrl[0].$parsers.push(function(txt) {
var dirsep = SystemInfo.state.DirectorySeparator || '/';
// Store type in scope for parseFilterContent directive
// This is necessary when changing directly the content (for example
// adding a '/' at the body end and then changing the filter type)
// This works because ng-repeat creates a child scope for each iteration
// It is still glitchy in some edge cases, but should be more consistent
scope.filterType = txt;
@@ -34,7 +36,7 @@ backupApp.directive('parseFilterContent', function(AppUtils, SystemInfo) {
link: function(scope, element, attr, ctrl) {
ctrl[0].$parsers.push(function(txt) {
var dirsep = SystemInfo.state.DirectorySeparator || '/';
// Store type in scope for parseFilterType directive
// Store content in scope for parseFilterType directive
scope.filterBody = txt;
return AppUtils.buildFilter(scope.filterType, txt, dirsep);
});
@@ -44,7 +46,7 @@ backupApp.directive('parseFilterContent', function(AppUtils, SystemInfo) {
// Remove double trailing slashes
var parts = AppUtils.splitFilterIntoTypeAndBody(src, dirsep);
if (parts == null) {
type = null;
scope.filterType = null;
return null;
}
@@ -316,6 +316,7 @@ backupApp.service('AppUtils', function($rootScope, $timeout, $cookies, DialogSer
return false;
} else if (k == 'include' || k == 'exclude') {
// Cannot specify filters in extra options
// Not sure that this is really called.
DialogService.dialog(gettextCatalog.getString('Error'), gettextCatalog.getString('Cannot specify filter include or excludes in extra options'));
return false;
}
@@ -659,7 +660,7 @@ backupApp.service('AppUtils', function($rootScope, $timeout, $cookies, DialogSer
this.evalFilter = function(path, filters, include) {
for (var i = 0; i < filters.length; i++) {
var m = path.match(filters[i][1]);
// Regex such as .* might match empty string at the end which is unwanted
// Regex such as '.*' might match empty string at the end which is unwanted
// Check that the first match covers the full string
if (m && m.length >= 1 && m[0].length == path.length)
return filters[i][0];