From 283671fa9d5a9a82431bb5059c657965929882de Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Wed, 4 Nov 2015 20:15:36 +0000 Subject: [PATCH] Remove old dead code --- lib/config/config.go | 31 ---------------- lib/config/config_test.go | 77 --------------------------------------- 2 files changed, 108 deletions(-) diff --git a/lib/config/config.go b/lib/config/config.go index c5443d68f..4f1d7fbd8 100644 --- a/lib/config/config.go +++ b/lib/config/config.go @@ -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 { diff --git a/lib/config/config_test.go b/lib/config/config_test.go index 0f95524e9..e043450c6 100644 --- a/lib/config/config_test.go +++ b/lib/config/config_test.go @@ -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 {