Remove old dead code

This commit is contained in:
Jakob Borg 2015-11-04 20:15:36 +00:00
parent 435c29755d
commit 283671fa9d
2 changed files with 0 additions and 108 deletions

View File

@ -247,37 +247,6 @@ func (cfg *Configuration) prepare(myID protocol.DeviceID) {
}
}
// ChangeRequiresRestart returns true if updating the configuration requires a
// complete restart.
func ChangeRequiresRestart(from, to Configuration) bool {
// Adding, removing or changing folders requires restart
if !reflect.DeepEqual(from.Folders, to.Folders) {
return true
}
// Removing a device requres restart
toDevs := make(map[protocol.DeviceID]bool, len(from.Devices))
for _, dev := range to.Devices {
toDevs[dev.DeviceID] = true
}
for _, dev := range from.Devices {
if _, ok := toDevs[dev.DeviceID]; !ok {
return true
}
}
// Changing usage reporting to on or off does not require a restart.
to.Options.URAccepted = from.Options.URAccepted
to.Options.URUniqueID = from.Options.URUniqueID
// All of the generic options require restart
if !reflect.DeepEqual(from.Options, to.Options) || !reflect.DeepEqual(from.GUI, to.GUI) {
return true
}
return false
}
func convertV11V12(cfg *Configuration) {
// Change listen address schema
for i, addr := range cfg.Options.ListenAddress {

View File

@ -463,83 +463,6 @@ func TestPrepare(t *testing.T) {
}
}
func TestRequiresRestart(t *testing.T) {
wr, err := Load("testdata/v6.xml", device1)
if err != nil {
t.Fatal(err)
}
cfg := wr.cfg
if ChangeRequiresRestart(cfg, cfg) {
t.Error("No change does not require restart")
}
newCfg := cfg
newCfg.Devices = append(newCfg.Devices, DeviceConfiguration{
DeviceID: device3,
})
if ChangeRequiresRestart(cfg, newCfg) {
t.Error("Adding a device does not require restart")
}
newCfg = cfg
newCfg.Devices = newCfg.Devices[:len(newCfg.Devices)-1]
if !ChangeRequiresRestart(cfg, newCfg) {
t.Error("Removing a device requires restart")
}
newCfg = cfg
newCfg.Folders = append(newCfg.Folders, FolderConfiguration{
ID: "t1",
RawPath: "t1",
})
if !ChangeRequiresRestart(cfg, newCfg) {
t.Error("Adding a folder requires restart")
}
newCfg = cfg
newCfg.Folders = newCfg.Folders[:len(newCfg.Folders)-1]
if !ChangeRequiresRestart(cfg, newCfg) {
t.Error("Removing a folder requires restart")
}
newCfg = cfg
newFolders := make([]FolderConfiguration, len(cfg.Folders))
copy(newFolders, cfg.Folders)
newCfg.Folders = newFolders
if ChangeRequiresRestart(cfg, newCfg) {
t.Error("No changes done yet")
}
newCfg.Folders[0].RawPath = "different"
if !ChangeRequiresRestart(cfg, newCfg) {
t.Error("Changing a folder requires restart")
}
newCfg = cfg
newDevices := make([]DeviceConfiguration, len(cfg.Devices))
copy(newDevices, cfg.Devices)
newCfg.Devices = newDevices
if ChangeRequiresRestart(cfg, newCfg) {
t.Error("No changes done yet")
}
newCfg.Devices[0].Name = "different"
if ChangeRequiresRestart(cfg, newCfg) {
t.Error("Changing a device does not require restart")
}
newCfg = cfg
newCfg.Options.GlobalAnnEnabled = !cfg.Options.GlobalAnnEnabled
if !ChangeRequiresRestart(cfg, newCfg) {
t.Error("Changing general options requires restart")
}
newCfg = cfg
newCfg.GUI.RawUseTLS = !cfg.GUI.RawUseTLS
if !ChangeRequiresRestart(cfg, newCfg) {
t.Error("Changing GUI options requires restart")
}
}
func TestCopy(t *testing.T) {
wrapper, err := Load("testdata/example.xml", device1)
if err != nil {