Rename TorrentData->Data
This commit is contained in:
parent
22746dda23
commit
315c703456
|
@ -410,7 +410,7 @@ func NewClient(cfg *Config) (cl *Client, err error) {
|
|||
disableTCP: cfg.DisableTCP,
|
||||
_configDir: cfg.ConfigDir,
|
||||
config: *cfg,
|
||||
torrentDataOpener: func(md *metainfo.Info) (TorrentData, error) {
|
||||
torrentDataOpener: func(md *metainfo.Info) (Data, error) {
|
||||
return filePkg.TorrentData(md, cfg.DataDir), nil
|
||||
},
|
||||
|
||||
|
@ -1544,7 +1544,7 @@ func (cl *Client) startTorrent(t *torrent) {
|
|||
}
|
||||
|
||||
// Storage cannot be changed once it's set.
|
||||
func (cl *Client) setStorage(t *torrent, td TorrentData) (err error) {
|
||||
func (cl *Client) setStorage(t *torrent, td Data) (err error) {
|
||||
err = t.setStorage(td)
|
||||
cl.event.Broadcast()
|
||||
if err != nil {
|
||||
|
@ -1554,7 +1554,7 @@ func (cl *Client) setStorage(t *torrent, td TorrentData) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
type TorrentDataOpener func(*metainfo.Info) (TorrentData, error)
|
||||
type TorrentDataOpener func(*metainfo.Info) (Data, error)
|
||||
|
||||
func (cl *Client) setMetaData(t *torrent, md metainfo.Info, bytes []byte) (err error) {
|
||||
err = t.setMetadata(md, bytes, &cl.mu)
|
||||
|
|
|
@ -195,7 +195,7 @@ func TestDownloadOnDemand(t *testing.T) {
|
|||
|
||||
NoDefaultBlocklist: true,
|
||||
|
||||
TorrentDataOpener: func(info *metainfo.Info) (torrent.TorrentData, error) {
|
||||
TorrentDataOpener: func(info *metainfo.Info) (torrent.Data, error) {
|
||||
return mmap.TorrentData(info, filepath.Join(layout.BaseDir, "download"))
|
||||
},
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ type peersKey struct {
|
|||
Port int
|
||||
}
|
||||
|
||||
type TorrentData interface {
|
||||
type Data interface {
|
||||
ReadAt(p []byte, off int64) (n int, err error)
|
||||
Close()
|
||||
WriteAt(p []byte, off int64) (n int, err error)
|
||||
|
@ -58,7 +58,7 @@ type torrent struct {
|
|||
Pieces []*piece
|
||||
length int64
|
||||
|
||||
data TorrentData
|
||||
data Data
|
||||
|
||||
Info *metainfo.Info
|
||||
// Active peer connections.
|
||||
|
@ -206,7 +206,7 @@ func (t *torrent) setMetadata(md metainfo.Info, infoBytes []byte, eventLocker sy
|
|||
return
|
||||
}
|
||||
|
||||
func (t *torrent) setStorage(td TorrentData) (err error) {
|
||||
func (t *torrent) setStorage(td Data) (err error) {
|
||||
if t.data != nil {
|
||||
t.data.Close()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue