From 3ac858b1500448f917104f1d1b3c7532a70feb42 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Wed, 17 Mar 2021 22:23:12 +0100 Subject: [PATCH] all: Remove miscellaneous vestigial code (#7495) --- lib/api/api.go | 4 ---- lib/connections/quic_dial.go | 5 +---- lib/db/benchmark_test.go | 2 +- lib/db/schemaupdater.go | 3 --- lib/db/structs.go | 27 --------------------------- lib/events/events.go | 1 - lib/model/blockpullreorderer_test.go | 6 ++---- lib/model/indexsender.go | 1 - lib/model/model.go | 10 ---------- lib/ur/usage_report.go | 5 +++++ 10 files changed, 9 insertions(+), 55 deletions(-) diff --git a/lib/api/api.go b/lib/api/api.go index 6aeeb1f1b..ecfe2581e 100644 --- a/lib/api/api.go +++ b/lib/api/api.go @@ -23,7 +23,6 @@ import ( "os" "path/filepath" "reflect" - "regexp" "runtime" "runtime/pprof" "sort" @@ -60,9 +59,6 @@ import ( "github.com/syncthing/syncthing/lib/ur" ) -// matches a bcrypt hash and not too much else -var bcryptExpr = regexp.MustCompile(`^\$2[aby]\$\d+\$.{50,}`) - const ( DefaultEventMask = events.AllEvents &^ events.LocalChangeDetected &^ events.RemoteChangeDetected DiskEventMask = events.LocalChangeDetected | events.RemoteChangeDetected diff --git a/lib/connections/quic_dial.go b/lib/connections/quic_dial.go index d502af439..3d905dc48 100644 --- a/lib/connections/quic_dial.go +++ b/lib/connections/quic_dial.go @@ -90,10 +90,7 @@ func (d *quicDialer) Dial(ctx context.Context, _ protocol.DeviceID, uri *url.URL return newInternalConn(&quicTlsConn{session, stream, createdConn}, connTypeQUICClient, quicPriority), nil } -type quicDialerFactory struct { - cfg config.Wrapper - tlsCfg *tls.Config -} +type quicDialerFactory struct{} func (quicDialerFactory) New(opts config.OptionsConfiguration, tlsCfg *tls.Config) genericDialer { return &quicDialer{commonDialer{ diff --git a/lib/db/benchmark_test.go b/lib/db/benchmark_test.go index 783ffdea4..d5e31696d 100644 --- a/lib/db/benchmark_test.go +++ b/lib/db/benchmark_test.go @@ -15,7 +15,7 @@ import ( "github.com/syncthing/syncthing/lib/protocol" ) -var files, filesUpdated, oneFile, firstHalf, secondHalf, changed100, unchanged100 []protocol.FileInfo +var files, oneFile, firstHalf, secondHalf, changed100, unchanged100 []protocol.FileInfo func lazyInitBenchFiles() { if files != nil { diff --git a/lib/db/schemaupdater.go b/lib/db/schemaupdater.go index 5d900fc50..a9d995ce2 100644 --- a/lib/db/schemaupdater.go +++ b/lib/db/schemaupdater.go @@ -8,7 +8,6 @@ package db import ( "bytes" - "errors" "fmt" "sort" "strings" @@ -32,8 +31,6 @@ type migration struct { migration func(prevSchema int) error } -var errFolderMissing = errors.New("folder present in global list but missing in keyer index") - type databaseDowngradeError struct { minSyncthingVersion string } diff --git a/lib/db/structs.go b/lib/db/structs.go index 9cdbc33e5..2443ea21a 100644 --- a/lib/db/structs.go +++ b/lib/db/structs.go @@ -396,25 +396,6 @@ func (vl *VersionList) findDevice(device []byte) (bool, int, int, bool) { return false, -1, -1, false } -func (vl *VersionList) popVersion(version protocol.Vector) (FileVersion, bool) { - i := vl.versionIndex(version) - if i == -1 { - return FileVersion{}, false - } - fv := vl.RawVersions[i] - vl.popVersionAt(i) - return fv, true -} - -func (vl *VersionList) versionIndex(version protocol.Vector) int { - for i, v := range vl.RawVersions { - if version.Equal(v.Version) { - return i - } - } - return -1 -} - func (vl *VersionList) popVersionAt(i int) { vl.RawVersions = append(vl.RawVersions[:i], vl.RawVersions[i+1:]...) } @@ -496,14 +477,6 @@ func popDeviceAt(devices [][]byte, i int) [][]byte { return append(devices[:i], devices[i+1:]...) } -func popDevice(devices [][]byte, device []byte) ([][]byte, bool) { - i := deviceIndex(devices, device) - if i == -1 { - return devices, false - } - return popDeviceAt(devices, i), true -} - func newFileVersion(device []byte, version protocol.Vector, invalid, deleted bool) FileVersion { fv := FileVersion{ Version: version, diff --git a/lib/events/events.go b/lib/events/events.go index c8c97e0c5..ba5343d83 100644 --- a/lib/events/events.go +++ b/lib/events/events.go @@ -237,7 +237,6 @@ type logger struct { events chan Event funcs chan func(context.Context) toUnsubscribe chan *subscription - stop chan struct{} } type Event struct { diff --git a/lib/model/blockpullreorderer_test.go b/lib/model/blockpullreorderer_test.go index f5cc7b4e5..c173f7c77 100644 --- a/lib/model/blockpullreorderer_test.go +++ b/lib/model/blockpullreorderer_test.go @@ -7,10 +7,11 @@ package model import ( - "github.com/syncthing/syncthing/lib/protocol" "reflect" "sort" "testing" + + "github.com/syncthing/syncthing/lib/protocol" ) var ( @@ -46,9 +47,6 @@ func Test_chunk(t *testing.T) { } func Test_inOrderBlockPullReorderer_Reorder(t *testing.T) { - type args struct { - blocks []protocol.BlockInfo - } tests := []struct { name string blocks []protocol.BlockInfo diff --git a/lib/model/indexsender.go b/lib/model/indexsender.go index f4fb9be86..af27245e5 100644 --- a/lib/model/indexsender.go +++ b/lib/model/indexsender.go @@ -25,7 +25,6 @@ type indexSender struct { conn protocol.Connection folder string folderIsReceiveEncrypted bool - dev string fset *db.FileSet prevSequence int64 evLogger events.Logger diff --git a/lib/model/model.go b/lib/model/model.go index f6d534794..b5ef20016 100644 --- a/lib/model/model.go +++ b/lib/model/model.go @@ -184,7 +184,6 @@ var ( errNetworkNotAllowed = errors.New("network not allowed") errNoVersioner = errors.New("folder has no versioner") // errors about why a connection is closed - errIgnoredFolderRemoved = errors.New("folder no longer ignored") errReplacingConnection = errors.New("replacing connection") errStopped = errors.New("Syncthing is being stopped") errEncryptionInvConfigLocal = errors.New("can't encrypt data for a device when the folder type is receiveEncrypted") @@ -1701,15 +1700,6 @@ func (m *model) handleAutoAccepts(deviceID protocol.DeviceID, folder protocol.Fo } } -func (m *model) newFolderConfiguration(id, label string, fsType fs.FilesystemType, path string) config.FolderConfiguration { - fcfg := m.cfg.DefaultFolder() - fcfg.ID = id - fcfg.Label = label - fcfg.FilesystemType = fsType - fcfg.Path = path - return fcfg -} - func (m *model) introduceDevice(device protocol.Device, introducerCfg config.DeviceConfiguration) config.DeviceConfiguration { addresses := []string{"dynamic"} for _, addr := range device.Addresses { diff --git a/lib/ur/usage_report.go b/lib/ur/usage_report.go index 544ce215b..35b8fc1ad 100644 --- a/lib/ur/usage_report.go +++ b/lib/ur/usage_report.go @@ -426,6 +426,11 @@ func CpuBench(ctx context.Context, iterations int, duration time.Duration, useWe perf = v } } + if blocksResult == nil { + // not looking at the blocksResult makes it unused from a static + // analysis / compiler standpoint... + panic("blocksResult should have been set by benchmark loop") + } blocksResult = nil return perf }