From 5b03c2d94991205eca18cdb7427a98439b90aa02 Mon Sep 17 00:00:00 2001 From: Audrius Butkevicius Date: Sun, 25 Oct 2015 20:46:09 +0000 Subject: [PATCH] Remove dead code --- cmd/syncthing/debug.go | 8 -------- lib/beacon/beacon.go | 4 ---- lib/discover/local.go | 32 -------------------------------- lib/model/model.go | 10 ---------- lib/model/rwfolder.go | 12 +----------- lib/sync/debug.go | 4 ---- test/scan_test.go | 2 +- 7 files changed, 2 insertions(+), 70 deletions(-) diff --git a/cmd/syncthing/debug.go b/cmd/syncthing/debug.go index d56a5efa8..d7c4d80d4 100644 --- a/cmd/syncthing/debug.go +++ b/cmd/syncthing/debug.go @@ -22,11 +22,3 @@ func init() { l.SetDebug("main", strings.Contains(os.Getenv("STTRACE"), "main") || os.Getenv("STTRACE") == "all") l.SetDebug("http", strings.Contains(os.Getenv("STTRACE"), "http") || os.Getenv("STTRACE") == "all") } - -func shouldDebugMain() bool { - return l.ShouldDebug("main") -} - -func shouldDebugHTTP() bool { - return l.ShouldDebug("http") -} diff --git a/lib/beacon/beacon.go b/lib/beacon/beacon.go index bafc6aa9b..8f84588b8 100644 --- a/lib/beacon/beacon.go +++ b/lib/beacon/beacon.go @@ -25,10 +25,6 @@ type Interface interface { Error() error } -type readerFrom interface { - ReadFrom([]byte) (int, net.Addr, error) -} - type errorHolder struct { err error mut stdsync.Mutex // uses stdlib sync as I want this to be trivially embeddable, and there is no risk of blocking diff --git a/lib/discover/local.go b/lib/discover/local.go index 01536de59..94dfc8a79 100644 --- a/lib/discover/local.go +++ b/lib/discover/local.go @@ -10,7 +10,6 @@ import ( "bytes" "encoding/hex" "errors" - "fmt" "io" "net" "net/url" @@ -238,34 +237,3 @@ func (c *localClient) registerDevice(src net.Addr, device Device) bool { return isNewDevice } - -func addrToAddr(addr *net.TCPAddr) string { - if len(addr.IP) == 0 || addr.IP.IsUnspecified() { - return fmt.Sprintf(":%c", addr.Port) - } else if bs := addr.IP.To4(); bs != nil { - return net.JoinHostPort(bs.String(), strconv.Itoa(addr.Port)) - } else if bs := addr.IP.To16(); bs != nil { - return net.JoinHostPort(bs.String(), strconv.Itoa(addr.Port)) - } - return "" -} - -func resolveAddrs(addrs []string) []string { - var raddrs []string - for _, addrStr := range addrs { - uri, err := url.Parse(addrStr) - if err != nil { - continue - } - addrRes, err := net.ResolveTCPAddr("tcp", uri.Host) - if err != nil { - continue - } - addr := addrToAddr(addrRes) - if len(addr) > 0 { - uri.Host = addr - raddrs = append(raddrs, uri.String()) - } - } - return raddrs -} diff --git a/lib/model/model.go b/lib/model/model.go index d5eacac0b..f305b709f 100644 --- a/lib/model/model.go +++ b/lib/model/model.go @@ -354,16 +354,6 @@ func (m *Model) Completion(device protocol.DeviceID, folder string) float64 { return completionPct } -func sizeOf(fs []protocol.FileInfo) (files, deleted int, bytes int64) { - for _, f := range fs { - fs, de, by := sizeOfFile(f) - files += fs - deleted += de - bytes += by - } - return -} - func sizeOfFile(f db.FileIntf) (files, deleted int, bytes int64) { if !f.IsDeleted() { files++ diff --git a/lib/model/rwfolder.go b/lib/model/rwfolder.go index a855b200b..4dedbbef0 100644 --- a/lib/model/rwfolder.go +++ b/lib/model/rwfolder.go @@ -49,7 +49,7 @@ const retainBits = os.ModeSetgid | os.ModeSetuid | os.ModeSticky var ( activity = newDeviceActivity() - errNoDevice = errors.New("peers who had this file went away, or the file has changed while syncing. will retry later.") + errNoDevice = errors.New("peers who had this file went away, or the file has changed while syncing. will retry later") ) const ( @@ -1429,16 +1429,6 @@ func (p *rwFolder) inConflict(current, replacement protocol.Vector) bool { return false } -func invalidateFolder(cfg *config.Configuration, folderID string, err error) { - for i := range cfg.Folders { - folder := &cfg.Folders[i] - if folder.ID == folderID { - folder.Invalid = err.Error() - return - } - } -} - func removeDevice(devices []protocol.DeviceID, device protocol.DeviceID) []protocol.DeviceID { for i := range devices { if devices[i] == device { diff --git a/lib/sync/debug.go b/lib/sync/debug.go index fe5e8b400..678a717e0 100644 --- a/lib/sync/debug.go +++ b/lib/sync/debug.go @@ -33,7 +33,3 @@ func init() { } l.Debugf("Enabling lock logging at %v threshold", threshold) } - -func shouldDebug() bool { - return l.ShouldDebug("sync") -} diff --git a/test/scan_test.go b/test/scan_test.go index c19cb39fa..ee03100af 100644 --- a/test/scan_test.go +++ b/test/scan_test.go @@ -29,7 +29,7 @@ func TestSubScan(t *testing.T) { t.Fatal(err) } - // 1. Scan a single file in a known directory "file1.txt" + // 1. Scan a single file it a known directory "file1.txt" // 2. Scan a single file in an unknown directory "filetest/file1.txt" // 3. Scan a single file in a deep unknown directory "filetest/1/2/3/4/5/6/7/file1.txt" // 4. Scan a directory in a deep unknown directory "dirtest/1/2/3/4/5/6/7"