gui: Add GUI control for versioning cleanup interval (ref #6693) (#6834)

This commit is contained in:
Jakob Borg 2020-07-14 17:35:09 +02:00 committed by GitHub
parent cd8e1ec738
commit aaecf813e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 11 deletions

View File

@ -1739,6 +1739,7 @@ angular.module('syncthing.core')
$scope.currentFolder.trashcanFileVersioning = true;
$scope.currentFolder.fileVersioningSelector = "trashcan";
$scope.currentFolder.trashcanClean = +$scope.currentFolder.versioning.params.cleanoutDays;
$scope.currentFolder.versioningCleanupIntervalS = +$scope.currentFolder.versioning.cleanupIntervalS;
} else if ($scope.currentFolder.versioning && $scope.currentFolder.versioning.type === "simple") {
$scope.currentFolder.simpleFileVersioning = true;
$scope.currentFolder.fileVersioningSelector = "simple";
@ -1749,6 +1750,7 @@ angular.module('syncthing.core')
$scope.currentFolder.staggeredMaxAge = Math.floor(+$scope.currentFolder.versioning.params.maxAge / 86400);
$scope.currentFolder.staggeredCleanInterval = +$scope.currentFolder.versioning.params.cleanInterval;
$scope.currentFolder.staggeredVersionsPath = $scope.currentFolder.versioning.params.versionsPath;
$scope.currentFolder.versioningCleanupIntervalS = +$scope.currentFolder.versioning.cleanupIntervalS;
} else if ($scope.currentFolder.versioning && $scope.currentFolder.versioning.type === "external") {
$scope.currentFolder.externalFileVersioning = true;
$scope.currentFolder.fileVersioningSelector = "external";
@ -1760,6 +1762,7 @@ angular.module('syncthing.core')
$scope.currentFolder.simpleKeep = $scope.currentFolder.simpleKeep || 5;
$scope.currentFolder.staggeredCleanInterval = $scope.currentFolder.staggeredCleanInterval || 3600;
$scope.currentFolder.staggeredVersionsPath = $scope.currentFolder.staggeredVersionsPath || "";
$scope.currentFolder.versioningCleanupIntervalS = $scope.currentFolder.versioningCleanupIntervalS || 0;
// staggeredMaxAge can validly be zero, which we should not replace
// with the default value of 365. So only set the default if it's
@ -1863,19 +1866,21 @@ angular.module('syncthing.core')
if (folderCfg.fileVersioningSelector === "trashcan") {
folderCfg.versioning = {
'Type': 'trashcan',
'Params': {
'type': 'trashcan',
'params': {
'cleanoutDays': '' + folderCfg.trashcanClean
}
},
'cleanupIntervalS': folderCfg.versioningCleanupIntervalS
};
delete folderCfg.trashcanFileVersioning;
delete folderCfg.trashcanClean;
} else if (folderCfg.fileVersioningSelector === "simple") {
folderCfg.versioning = {
'Type': 'simple',
'Params': {
'type': 'simple',
'params': {
'keep': '' + folderCfg.simpleKeep
}
},
'cleanupIntervalS': folderCfg.versioningCleanupIntervalS
};
delete folderCfg.simpleFileVersioning;
delete folderCfg.simpleKeep;
@ -1886,19 +1891,20 @@ angular.module('syncthing.core')
'maxAge': '' + (folderCfg.staggeredMaxAge * 86400),
'cleanInterval': '' + folderCfg.staggeredCleanInterval,
'versionsPath': '' + folderCfg.staggeredVersionsPath
}
},
'cleanupIntervalS': folderCfg.versioningCleanupIntervalS
};
delete folderCfg.staggeredFileVersioning;
delete folderCfg.staggeredMaxAge;
delete folderCfg.staggeredCleanInterval;
delete folderCfg.staggeredVersionsPath;
} else if (folderCfg.fileVersioningSelector === "external") {
folderCfg.versioning = {
'Type': 'external',
'Params': {
'type': 'external',
'params': {
'command': '' + folderCfg.externalCommand
}
},
'cleanupIntervalS': folderCfg.versioningCleanupIntervalS
};
delete folderCfg.externalFileVersioning;
delete folderCfg.externalCommand;

View File

@ -144,6 +144,18 @@
<span translate ng-if="folderEditor.externalCommand.$error.required && folderEditor.externalCommand.$dirty">The path cannot be blank.</span>
</p>
</div>
<div class="form-group" ng-if="currentFolder.fileVersioningSelector == 'staggered' || currentFolder.fileVersioningSelector == 'trashcan'" ng-class="{'has-error': folderEditor.versioningCleanupIntervalS.$invalid && folderEditor.versioningCleanupIntervalS.$dirty}">
<label translate for="versioningCleanupIntervalS">Cleanup Interval</label>
<div class="input-group">
<input name="versioningCleanupIntervalS" id="versioningCleanupIntervalS" class="form-control text-right" type="number" ng-model="currentFolder.versioningCleanupIntervalS" required="" min="0" max="31536000" aria-required="true" />
<div class="input-group-addon" translate>seconds</div>
</div>
<p class="help-block">
<span translate ng-if="folderEditor.versioningCleanupIntervalS.$valid || folderEditor.versioningCleanupIntervalS.$pristine"class="help-block">The interval, in seconds, for running cleanup in the versions directory. Zero to disable periodic cleaning.</span>
<span translate ng-if="folderEditor.versioningCleanupIntervalS.$error.required && folderEditor.versioningCleanupIntervalS.$dirty">The cleanup interval cannot be blank.</span>
<span translate ng-if="folderEditor.versioningCleanupIntervalS.$error.min && folderEditor.versioningCleanupIntervalS.$dirty">The interval must be a positive number of seconds.</span>
</p>
</div>
</div>
<div id="folder-ignores" class="tab-pane">