Set defaults correctly for autoNormalize

The default:"foo" struct tags aren't actually used for folder configs.
This commit is contained in:
Jakob Borg
2015-03-22 10:26:51 +01:00
parent 963d8121d9
commit a595e814dd
5 changed files with 33 additions and 8 deletions
@@ -934,6 +934,7 @@ angular.module('syncthing.core')
$scope.currentFolder.staggeredMaxAge = 365;
$scope.currentFolder.staggeredCleanInterval = 3600;
$scope.currentFolder.staggeredVersionsPath = "";
$scope.currentFolder.autoNormalize = true;
$scope.editingExisting = false;
$scope.folderEditor.$setPristine();
$('#editFolder').modal();
@@ -953,6 +954,7 @@ angular.module('syncthing.core')
$scope.currentFolder.staggeredMaxAge = 365;
$scope.currentFolder.staggeredCleanInterval = 3600;
$scope.currentFolder.staggeredVersionsPath = "";
$scope.currentFolder.autoNormalize = true;
$scope.editingExisting = false;
$scope.folderEditor.$setPristine();
$('#editFolder').modal();
File diff suppressed because one or more lines are too long
+17 -7
View File
@@ -27,7 +27,7 @@ import (
var l = logger.DefaultLogger
const CurrentVersion = 9
const CurrentVersion = 10
type Configuration struct {
Version int `xml:"version,attr"`
@@ -44,19 +44,18 @@ type Configuration struct {
}
type FolderConfiguration struct {
<<<<<<< HEAD
ID string `xml:"id,attr"`
Path string `xml:"path,attr"`
Devices []FolderDeviceConfiguration `xml:"device"`
ReadOnly bool `xml:"ro,attr"`
RescanIntervalS int `xml:"rescanIntervalS,attr" default:"60"`
RescanIntervalS int `xml:"rescanIntervalS,attr"`
IgnorePerms bool `xml:"ignorePerms,attr"`
AutoNormalize bool `xml:"autoNormalize,attr" default:"true"`
AutoNormalize bool `xml:"autoNormalize,attr"`
Versioning VersioningConfiguration `xml:"versioning"`
LenientMtimes bool `xml:"lenientMtimes"`
Copiers int `xml:"copiers" default:"1"` // This defines how many files are handled concurrently.
Pullers int `xml:"pullers" default:"16"` // Defines how many blocks are fetched at the same time, possibly between separate copier routines.
Hashers int `xml:"hashers" default:"0"` // Less than one sets the value to the number of cores. These are CPU bound due to hashing.
Copiers int `xml:"copiers"` // This defines how many files are handled concurrently.
Pullers int `xml:"pullers"` // Defines how many blocks are fetched at the same time, possibly between separate copier routines.
Hashers int `xml:"hashers"` // Less than one sets the value to the number of cores. These are CPU bound due to hashing.
Invalid string `xml:"-"` // Set at runtime when there is an error, not saved
@@ -316,6 +315,9 @@ func (cfg *Configuration) prepare(myID protocol.DeviceID) {
if cfg.Version == 8 {
convertV8V9(cfg)
}
if cfg.Version == 9 {
convertV9V10(cfg)
}
// Hash old cleartext passwords
if len(cfg.GUI.Password) > 0 && cfg.GUI.Password[0] != '$' {
@@ -407,6 +409,14 @@ func ChangeRequiresRestart(from, to Configuration) bool {
return false
}
func convertV9V10(cfg *Configuration) {
// Enable auto normalization on existing folders.
for i := range cfg.Folders {
cfg.Folders[i].AutoNormalize = true
}
cfg.Version = 10
}
func convertV8V9(cfg *Configuration) {
// Compression is interpreted and serialized differently, but no enforced
// changes. Still need a new version number since the compression stuff
+1
View File
@@ -83,6 +83,7 @@ func TestDeviceConfig(t *testing.T) {
Copiers: 1,
Pullers: 16,
Hashers: 0,
AutoNormalize: true,
},
}
expectedDevices := []DeviceConfiguration{
+12
View File
@@ -0,0 +1,12 @@
<configuration version="10">
<folder id="test" path="testdata" ro="true" ignorePerms="false" rescanIntervalS="600" autoNormalize="true">
<device id="AIR6LPZ-7K4PTTV-UXQSMUU-CPQ5YWH-OEDFIIQ-JUG777G-2YQXXR5-YD6AWQR"></device>
<device id="P56IOI7-MZJNU2Y-IQGDREY-DM2MGTI-MGL3BXN-PQ6W5BM-TBBZ4TJ-XZWICQ2"></device>
</folder>
<device id="AIR6LPZ-7K4PTTV-UXQSMUU-CPQ5YWH-OEDFIIQ-JUG777G-2YQXXR5-YD6AWQR" name="node one" compression="metadata">
<address>a</address>
</device>
<device id="P56IOI7-MZJNU2Y-IQGDREY-DM2MGTI-MGL3BXN-PQ6W5BM-TBBZ4TJ-XZWICQ2" name="node two" compression="metadata">
<address>b</address>
</device>
</configuration>