From 02ea8b1081c91b6cad9f7f3427c4757fa3e7178b Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Mon, 16 May 2016 21:50:43 +1000 Subject: [PATCH] Rename storage.I->Client --- client.go | 4 ++-- client_test.go | 14 +++++++------- config.go | 2 +- storage/file.go | 2 +- storage/interface.go | 2 +- storage/mmap.go | 2 +- storage/piece_file.go | 2 +- storage/piece_resource.go | 2 +- torrent.go | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/client.go b/client.go index a791c568..c92f7c2c 100644 --- a/client.go +++ b/client.go @@ -73,7 +73,7 @@ type Client struct { // through legitimate channels. dopplegangerAddrs map[string]struct{} - defaultStorage storage.I + defaultStorage storage.Client mu sync.RWMutex event sync.Cond @@ -1486,7 +1486,7 @@ type TorrentSpec struct { // The chunk size to use for outbound requests. Defaults to 16KiB if not // set. ChunkSize int - Storage storage.I + Storage storage.Client } func TorrentSpecFromMagnetURI(uri string) (spec *TorrentSpec, err error) { diff --git a/client_test.go b/client_test.go index e2b5ac73..644a8a69 100644 --- a/client_test.go +++ b/client_test.go @@ -243,11 +243,11 @@ func TestClientTransferDefault(t *testing.T) { }) } -func fileCachePieceResourceStorage(fc *filecache.Cache) storage.I { +func fileCachePieceResourceStorage(fc *filecache.Cache) storage.Client { return storage.NewPiecePerResource(fc.AsResourceProvider()) } -func fileCachePieceFileStorage(fc *filecache.Cache) storage.I { +func fileCachePieceFileStorage(fc *filecache.Cache) storage.Client { return storage.NewPieceFileStorage(fc.AsFileStore()) } @@ -267,11 +267,11 @@ func TestClientTransferSmallCache(t *testing.T) { } func TestClientTransferVarious(t *testing.T) { - for _, lsf := range []func(*filecache.Cache) storage.I{ + for _, lsf := range []func(*filecache.Cache) storage.Client{ fileCachePieceFileStorage, fileCachePieceResourceStorage, } { - for _, ss := range []func(string) storage.I{ + for _, ss := range []func(string) storage.Client{ storage.NewFile, storage.NewMMap, } { @@ -302,8 +302,8 @@ type testClientTransferParams struct { ExportClientStatus bool SetLeecherStorageCapacity bool LeecherStorageCapacity int64 - LeecherFileCachePieceStorageFactory func(*filecache.Cache) storage.I - SeederStorage func(string) storage.I + LeecherFileCachePieceStorageFactory func(*filecache.Cache) storage.Client + SeederStorage func(string) storage.Client } func testClientTransfer(t *testing.T, ps testClientTransferParams) { @@ -696,7 +696,7 @@ func writeTorrentData(ts storage.Torrent, info *metainfo.InfoEx, b []byte) { } } -func testAddTorrentPriorPieceCompletion(t *testing.T, alreadyCompleted bool, csf func(*filecache.Cache) storage.I) { +func testAddTorrentPriorPieceCompletion(t *testing.T, alreadyCompleted bool, csf func(*filecache.Cache) storage.Client) { fileCacheDir, err := ioutil.TempDir("", "") require.NoError(t, err) defer os.RemoveAll(fileCacheDir) diff --git a/config.go b/config.go index 1a9ab8be..9f645b0a 100644 --- a/config.go +++ b/config.go @@ -35,7 +35,7 @@ type Config struct { DisableTCP bool `long:"disable-tcp"` // Called to instantiate storage for each added torrent. Provided backends // are in $REPO/data. If not set, the "file" implementation is used. - DefaultStorage storage.I + DefaultStorage storage.Client DisableEncryption bool `long:"disable-encryption"` IPBlocklist iplist.Ranger diff --git a/storage/file.go b/storage/file.go index 1b7ed749..f7815753 100644 --- a/storage/file.go +++ b/storage/file.go @@ -17,7 +17,7 @@ type fileStorage struct { completed map[[20]byte]bool } -func NewFile(baseDir string) I { +func NewFile(baseDir string) Client { return &fileStorage{ baseDir: baseDir, } diff --git a/storage/interface.go b/storage/interface.go index 71b34abd..b2c3724e 100644 --- a/storage/interface.go +++ b/storage/interface.go @@ -7,7 +7,7 @@ import ( ) // Represents data storage for an unspecified torrent. -type I interface { +type Client interface { OpenTorrent(info *metainfo.InfoEx) (Torrent, error) } diff --git a/storage/mmap.go b/storage/mmap.go index 0a05bf73..76b6d79c 100644 --- a/storage/mmap.go +++ b/storage/mmap.go @@ -17,7 +17,7 @@ type mmapStorage struct { baseDir string } -func NewMMap(baseDir string) I { +func NewMMap(baseDir string) Client { return &mmapStorage{ baseDir: baseDir, } diff --git a/storage/piece_file.go b/storage/piece_file.go index ee7608c1..8a644d68 100644 --- a/storage/piece_file.go +++ b/storage/piece_file.go @@ -15,7 +15,7 @@ type pieceFileStorage struct { fs missinggo.FileStore } -func NewPieceFileStorage(fs missinggo.FileStore) I { +func NewPieceFileStorage(fs missinggo.FileStore) Client { return &pieceFileStorage{ fs: fs, } diff --git a/storage/piece_resource.go b/storage/piece_resource.go index 2f6d6eef..f87d3f0d 100644 --- a/storage/piece_resource.go +++ b/storage/piece_resource.go @@ -14,7 +14,7 @@ type piecePerResource struct { p uniform.Provider } -func NewPiecePerResource(p uniform.Provider) I { +func NewPiecePerResource(p uniform.Provider) Client { return &piecePerResource{ p: p, } diff --git a/torrent.go b/torrent.go index 296db4be..b89ce948 100644 --- a/torrent.go +++ b/torrent.go @@ -51,7 +51,7 @@ type Torrent struct { length int64 // The storage to open when the info dict becomes available. - storageOpener storage.I + storageOpener storage.Client // Storage for torrent data. storage storage.Torrent -- 2.48.1