From 3dbcf0af2deb8f3d9880cea3a1ea2927d9a6102d Mon Sep 17 00:00:00 2001 From: Lars Lehtonen Date: Wed, 12 Feb 2020 03:23:57 -0800 Subject: [PATCH] backend/cache: Remove Unused Functions This removes the unused functions run.writeRemoteRandomBytes() run.writeObjectRandomBytes() run.listPath() Directory.parentRemote() and Persistent.dumpRoot(). --- backend/cache/cache_internal_test.go | 38 ---------------------------- backend/cache/directory.go | 9 ------- backend/cache/storage_persistent.go | 25 ------------------ 3 files changed, 72 deletions(-) diff --git a/backend/cache/cache_internal_test.go b/backend/cache/cache_internal_test.go index d183f2a23..b6ee2a057 100644 --- a/backend/cache/cache_internal_test.go +++ b/backend/cache/cache_internal_test.go @@ -17,7 +17,6 @@ import ( "path/filepath" "runtime" "runtime/debug" - "strconv" "strings" "testing" "time" @@ -1139,23 +1138,6 @@ func (r *run) randomReader(t *testing.T, size int64) io.ReadCloser { return f } -func (r *run) writeRemoteRandomBytes(t *testing.T, f fs.Fs, p string, size int64) string { - remote := path.Join(p, strconv.Itoa(rand.Int())+".bin") - // create some rand test data - testData := randStringBytes(int(size)) - - r.writeRemoteBytes(t, f, remote, testData) - return remote -} - -func (r *run) writeObjectRandomBytes(t *testing.T, f fs.Fs, p string, size int64) fs.Object { - remote := path.Join(p, strconv.Itoa(rand.Int())+".bin") - // create some rand test data - testData := randStringBytes(int(size)) - - return r.writeObjectBytes(t, f, remote, testData) -} - func (r *run) writeRemoteString(t *testing.T, f fs.Fs, remote, content string) { r.writeRemoteBytes(t, f, remote, []byte(content)) } @@ -1344,26 +1326,6 @@ func (r *run) list(t *testing.T, f fs.Fs, remote string) ([]interface{}, error) return l, err } -func (r *run) listPath(t *testing.T, f fs.Fs, remote string) []string { - var err error - var l []string - if r.useMount { - var list []os.FileInfo - list, err = ioutil.ReadDir(path.Join(r.mntDir, remote)) - for _, ll := range list { - l = append(l, ll.Name()) - } - } else { - var list fs.DirEntries - list, err = f.List(context.Background(), remote) - for _, ll := range list { - l = append(l, ll.Remote()) - } - } - require.NoError(t, err) - return l -} - func (r *run) copyFile(t *testing.T, f fs.Fs, src, dst string) error { in, err := os.Open(src) if err != nil { diff --git a/backend/cache/directory.go b/backend/cache/directory.go index c95377712..2f03eb938 100644 --- a/backend/cache/directory.go +++ b/backend/cache/directory.go @@ -101,15 +101,6 @@ func (d *Directory) abs() string { return cleanPath(path.Join(d.Dir, d.Name)) } -// parentRemote returns the absolute path parent remote -func (d *Directory) parentRemote() string { - absPath := d.abs() - if absPath == "" { - return "" - } - return cleanPath(path.Dir(absPath)) -} - // ModTime returns the cached ModTime func (d *Directory) ModTime(ctx context.Context) time.Time { return time.Unix(0, d.CacheModTime) diff --git a/backend/cache/storage_persistent.go b/backend/cache/storage_persistent.go index 6221616f2..239dca02f 100644 --- a/backend/cache/storage_persistent.go +++ b/backend/cache/storage_persistent.go @@ -767,31 +767,6 @@ func (b *Persistent) iterateBuckets(buk *bolt.Bucket, bucketFn func(name string) return err } -func (b *Persistent) dumpRoot() string { - var itBuckets func(buk *bolt.Bucket) map[string]interface{} - - itBuckets = func(buk *bolt.Bucket) map[string]interface{} { - m := make(map[string]interface{}) - c := buk.Cursor() - for k, v := c.First(); k != nil; k, v = c.Next() { - if v == nil { - buk2 := buk.Bucket(k) - m[string(k)] = itBuckets(buk2) - } else { - m[string(k)] = "-" - } - } - return m - } - var mm map[string]interface{} - _ = b.db.View(func(tx *bolt.Tx) error { - mm = itBuckets(tx.Bucket([]byte(RootBucket))) - return nil - }) - raw, _ := json.MarshalIndent(mm, "", " ") - return string(raw) -} - // addPendingUpload adds a new file to the pending queue of uploads func (b *Persistent) addPendingUpload(destPath string, started bool) error { return b.db.Update(func(tx *bolt.Tx) error {