Repository: syncthing/syncthing
File: gui/default/syncthing/core/syncthingController.js (JavaScript)

Code before:
            delete $scope.currentSharing;

            if (!folderCfg.versioning) {
                folderCfg.versioning = {params: {}};
            }
            folderCfg.versioning.type = folderCfg._guiVersioning.selector;
            if ($scope.internalVersioningEnabled()) {
                folderCfg.versioning.cleanupIntervalS = folderCfg._guiVersioning.cleanupIntervalS;
            }
            switch (folderCfg._guiVersioning.selector) {
            case "trashcan":
                folderCfg.versioning.params.cleanoutDays = '' + folderCfg._guiVersioning.trashcanClean;
                break;
            case "simple":
                folderCfg.versioning.params.keep = '' + folderCfg._guiVersioning.simpleKeep,
                folderCfg.versioning.params.cleanoutDays = '' + folderCfg._guiVersioning.trashcanClean;
                break;
            case "staggered":
                folderCfg.versioning.params.maxAge = '' + (folderCfg._guiVersioning.staggeredMaxAge * 86400);
                folderCfg.versioning.params.cleanInterval = '' + folderCfg._guiVersioning.staggeredCleanInterval;
                break;
            case "external":
                folderCfg.versioning.params.command = '' + folderCfg._guiVersioning.externalCommand;
                break;
            default:
                folderCfg.versioning.type = '';
            }
            delete folderCfg._guiVersioning;

            if ($scope.editingDefaults) {
                $scope.config.defaults.folder = folderCfg;
                $scope.saveConfig();
            } else {
                saveFolderExisting(folderCfg);
            }
        };

        function saveFolderExisting(folderCfg) {
            var ignoresLoaded = !$scope.ignores.disabled;
            var ignores = $scope.ignores.text.split('\n');
            // Split always returns a minimum 1-length array even for no patterns
            if (ignores.length === 1 && ignores[0] === "") {
                ignores = [];
            }
            if (!$scope.editingExisting && ignores.length) {
                folderCfg.paused = true;
            };

            $scope.folders[folderCfg.id] = folderCfg;
            $scope.config.folders = folderList($scope.folders);


Review comment (suggestion):
This means we retain various options like staggered times and whatnot but with empty type? Or is that cleaned up in some other place? (I guess `folderCfg.versioning = {type: ''} // nothing` would resolve this otherwise.)

Code after:
            delete $scope.currentSharing;

            if (!folderCfg.versioning) {
                folderCfg.versioning = {params: {}};
            }
            folderCfg.versioning.type = folderCfg._guiVersioning.selector;
            if ($scope.internalVersioningEnabled()) {
                folderCfg.versioning.cleanupIntervalS = folderCfg._guiVersioning.cleanupIntervalS;
            }
            switch (folderCfg._guiVersioning.selector) {
            case "trashcan":
                folderCfg.versioning.params.cleanoutDays = '' + folderCfg._guiVersioning.trashcanClean;
                break;
            case "simple":
                folderCfg.versioning.params.keep = '' + folderCfg._guiVersioning.simpleKeep,
                folderCfg.versioning.params.cleanoutDays = '' + folderCfg._guiVersioning.trashcanClean;
                break;
            case "staggered":
                folderCfg.versioning.params.maxAge = '' + (folderCfg._guiVersioning.staggeredMaxAge * 86400);
                folderCfg.versioning.params.cleanInterval = '' + folderCfg._guiVersioning.staggeredCleanInterval;
                break;
            case "external":
                folderCfg.versioning.params.command = '' + folderCfg._guiVersioning.externalCommand;
                break;
            default:
                folderCfg.versioning = {type: ''};
            }
            delete folderCfg._guiVersioning;

            if ($scope.editingDefaults) {
                $scope.config.defaults.folder = folderCfg;
                $scope.saveConfig();
            } else {
                saveFolderExisting(folderCfg);
            }
        };

        function saveFolderExisting(folderCfg) {
            var ignoresLoaded = !$scope.ignores.disabled;
            var ignores = $scope.ignores.text.split('\n');
            // Split always returns a minimum 1-length array even for no patterns
            if (ignores.length === 1 && ignores[0] === "") {
                ignores = [];
            }
            if (!$scope.editingExisting && ignores.length) {
                folderCfg.paused = true;
            };

            $scope.folders[folderCfg.id] = folderCfg;
            $scope.config.folders = folderList($scope.folders);