From 1dfd3b8aa3274f36789023efd1e1d0165ba5ba7e Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 21 Sep 2016 20:22:32 +0200 Subject: [PATCH] Remove unused bits and pieces Reported by https://github.com/dominikh/go-unused --- src/restic/backend/test/tests.go | 9 --------- src/restic/checker/checker_test.go | 11 ----------- src/restic/crypto/buffer_pool.go | 19 ------------------- src/restic/index/index.go | 2 -- src/restic/index/index_test.go | 1 - src/restic/node.go | 1 - src/restic/pipe/pipe.go | 6 ------ src/restic/pipe/pipe_test.go | 4 ---- src/restic/repository/index.go | 2 -- src/restic/repository/repository.go | 11 ----------- src/restic/repository/repository_test.go | 5 ----- 11 files changed, 71 deletions(-) delete mode 100644 src/restic/crypto/buffer_pool.go diff --git a/src/restic/backend/test/tests.go b/src/restic/backend/test/tests.go index e79fca366..c79d45041 100644 --- a/src/restic/backend/test/tests.go +++ b/src/restic/backend/test/tests.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" "io" - "io/ioutil" "math/rand" "reflect" "restic" @@ -471,14 +470,6 @@ func store(t testing.TB, b restic.Backend, tpe restic.FileType, data []byte) { test.OK(t, err) } -func read(t testing.TB, rd io.Reader, expectedData []byte) { - buf, err := ioutil.ReadAll(rd) - test.OK(t, err) - if expectedData != nil { - test.Equals(t, expectedData, buf) - } -} - // TestBackend tests all functions of the backend. func TestBackend(t testing.TB) { b := open(t) diff --git a/src/restic/checker/checker_test.go b/src/restic/checker/checker_test.go index 2e6075be7..26528d24a 100644 --- a/src/restic/checker/checker_test.go +++ b/src/restic/checker/checker_test.go @@ -16,17 +16,6 @@ import ( var checkerTestData = filepath.Join("testdata", "checker-test-repo.tar.gz") -func list(repo restic.Repository, t restic.FileType) (IDs []string) { - done := make(chan struct{}) - defer close(done) - - for id := range repo.List(t, done) { - IDs = append(IDs, id.String()) - } - - return IDs -} - func collectErrors(f func(chan<- error, <-chan struct{})) (errs []error) { done := make(chan struct{}) defer close(done) diff --git a/src/restic/crypto/buffer_pool.go b/src/restic/crypto/buffer_pool.go deleted file mode 100644 index da69b8fe3..000000000 --- a/src/restic/crypto/buffer_pool.go +++ /dev/null @@ -1,19 +0,0 @@ -package crypto - -import "sync" - -const defaultBufSize = 32 * 1024 // 32KiB - -var bufPool = sync.Pool{ - New: func() interface{} { - return make([]byte, defaultBufSize) - }, -} - -func getBuffer() []byte { - return bufPool.Get().([]byte) -} - -func freeBuffer(buf []byte) { - bufPool.Put(buf) -} diff --git a/src/restic/index/index.go b/src/restic/index/index.go index 9027e3fda..255e72d9e 100644 --- a/src/restic/index/index.go +++ b/src/restic/index/index.go @@ -77,8 +77,6 @@ func New(repo restic.Repository, p *restic.Progress) (*Index, error) { return idx, nil } -const loadIndexParallelism = 20 - type packJSON struct { ID restic.ID `json:"id"` Blobs []blobJSON `json:"blobs"` diff --git a/src/restic/index/index_test.go b/src/restic/index/index_test.go index 608ff944a..7905f7368 100644 --- a/src/restic/index/index_test.go +++ b/src/restic/index/index_test.go @@ -10,7 +10,6 @@ import ( var ( snapshotTime = time.Unix(1470492820, 207401672) - snapshots = 3 depth = 3 ) diff --git a/src/restic/node.go b/src/restic/node.go index 0a8624f5d..921be7382 100644 --- a/src/restic/node.go +++ b/src/restic/node.go @@ -43,7 +43,6 @@ type Node struct { tree *Tree Path string `json:"-"` - err error } func (node Node) String() string { diff --git a/src/restic/pipe/pipe.go b/src/restic/pipe/pipe.go index 1ed9b6162..5db01375b 100644 --- a/src/restic/pipe/pipe.go +++ b/src/restic/pipe/pipe.go @@ -74,12 +74,6 @@ func readDirNames(dirname string) ([]string, error) { return names, nil } -func isDir(fi os.FileInfo) bool { - return fi.IsDir() -} - -var errCancelled = errors.New("walk cancelled") - // SelectFunc returns true for all items that should be included (files and // dirs). If false is returned, files are ignored and dirs are not even walked. type SelectFunc func(item string, fi os.FileInfo) bool diff --git a/src/restic/pipe/pipe_test.go b/src/restic/pipe/pipe_test.go index 719670aaa..dd2c5e02d 100644 --- a/src/restic/pipe/pipe_test.go +++ b/src/restic/pipe/pipe_test.go @@ -14,10 +14,6 @@ import ( . "restic/test" ) -func isFile(fi os.FileInfo) bool { - return fi.Mode()&(os.ModeType|os.ModeCharDevice) == 0 -} - type stats struct { dirs, files int } diff --git a/src/restic/repository/index.go b/src/restic/repository/index.go index 029374063..a372f82aa 100644 --- a/src/restic/repository/index.go +++ b/src/restic/repository/index.go @@ -346,8 +346,6 @@ type jsonIndex struct { Packs []*packJSON `json:"packs"` } -type jsonOldIndex []*packJSON - // Encode writes the JSON serialization of the index to the writer w. func (idx *Index) Encode(w io.Writer) error { debug.Log("Index.Encode", "encoding index") diff --git a/src/restic/repository/repository.go b/src/restic/repository/repository.go index a7258e090..fe36e345f 100644 --- a/src/restic/repository/repository.go +++ b/src/restic/repository/repository.go @@ -4,7 +4,6 @@ import ( "bytes" "encoding/json" "fmt" - "io" "os" "restic" @@ -156,16 +155,6 @@ func (r *Repository) loadBlob(id restic.ID, t restic.BlobType, plaintextBuf []by return 0, errors.Errorf("loading blob %v from %v packs failed", id.Str(), len(blobs)) } -// closeOrErr calls cl.Close() and sets err to the returned error value if -// itself is not yet set. -func closeOrErr(cl io.Closer, err *error) { - e := cl.Close() - if *err != nil { - return - } - *err = e -} - // LoadJSONUnpacked decrypts the data and afterwards calls json.Unmarshal on // the item. func (r *Repository) LoadJSONUnpacked(t restic.FileType, id restic.ID, item interface{}) (err error) { diff --git a/src/restic/repository/repository_test.go b/src/restic/repository/repository_test.go index ce4fb68ed..5934d4778 100644 --- a/src/restic/repository/repository_test.go +++ b/src/restic/repository/repository_test.go @@ -234,11 +234,6 @@ func TestRepositoryIncrementalIndex(t *testing.T) { // save final index OK(t, repo.SaveIndex()) - type packEntry struct { - id restic.ID - indexes []*repository.Index - } - packEntries := make(map[restic.ID]map[restic.ID]struct{}) for id := range repo.List(restic.IndexFile, nil) {