cmd utils fixed
This commit is contained in:
parent
5b790bf874
commit
052a899f60
|
@ -27,9 +27,9 @@ func main() {
|
|||
go func() {
|
||||
defer wg.Done()
|
||||
<-t.GotInfo()
|
||||
mi := t.MetaInfo()
|
||||
mi := t.Info()
|
||||
t.Drop()
|
||||
f, err := os.Create(mi.Info.Name + ".torrent")
|
||||
f, err := os.Create(mi.Name + ".torrent")
|
||||
if err != nil {
|
||||
log.Fatalf("error creating torrent metainfo file: %s", err)
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ func main() {
|
|||
|
||||
done := make(chan struct{})
|
||||
for _, arg := range posArgs {
|
||||
t := func() torrent.Torrent {
|
||||
t := func() torrent.Download {
|
||||
if strings.HasPrefix(arg, "magnet:") {
|
||||
t, err := client.AddMagnet(arg)
|
||||
if err != nil {
|
||||
|
|
|
@ -36,7 +36,7 @@ func resolvedPeerAddrs(ss []string) (ret []torrent.Peer, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func torrentBar(t torrent.Torrent) {
|
||||
func torrentBar(t torrent.Download) {
|
||||
bar := uiprogress.AddBar(1)
|
||||
bar.AppendCompleted()
|
||||
bar.AppendFunc(func(*uiprogress.Bar) (ret string) {
|
||||
|
@ -54,7 +54,7 @@ func torrentBar(t torrent.Torrent) {
|
|||
}
|
||||
})
|
||||
bar.PrependFunc(func(*uiprogress.Bar) string {
|
||||
return t.Name()
|
||||
return t.Info().Name
|
||||
})
|
||||
go func() {
|
||||
<-t.GotInfo()
|
||||
|
@ -69,7 +69,7 @@ func torrentBar(t torrent.Torrent) {
|
|||
|
||||
func addTorrents(client *torrent.Client) {
|
||||
for _, arg := range opts.Torrent {
|
||||
t := func() torrent.Torrent {
|
||||
t := func() torrent.Download {
|
||||
if strings.HasPrefix(arg, "magnet:") {
|
||||
t, err := client.AddMagnet(arg)
|
||||
if err != nil {
|
||||
|
|
|
@ -22,4 +22,5 @@ type Download interface {
|
|||
AddPeers(pp []Peer) error
|
||||
DownloadAll()
|
||||
Trackers() [][]tracker.Client
|
||||
Files() (ret []File)
|
||||
}
|
|
@ -50,7 +50,7 @@ type node struct {
|
|||
path string
|
||||
metadata *metainfo.Info
|
||||
FS *TorrentFS
|
||||
t torrent.Torrent
|
||||
t torrent.Download
|
||||
}
|
||||
|
||||
type fileNode struct {
|
||||
|
@ -69,7 +69,7 @@ func (n *node) fsPath() string {
|
|||
return "/" + n.metadata.Name + "/" + n.path
|
||||
}
|
||||
|
||||
func blockingRead(ctx context.Context, fs *TorrentFS, t torrent.Torrent, off int64, p []byte) (n int, err error) {
|
||||
func blockingRead(ctx context.Context, fs *TorrentFS, t torrent.Download, off int64, p []byte) (n int, err error) {
|
||||
fs.mu.Lock()
|
||||
fs.blockedReads++
|
||||
fs.event.Broadcast()
|
||||
|
@ -101,7 +101,7 @@ func blockingRead(ctx context.Context, fs *TorrentFS, t torrent.Torrent, off int
|
|||
return
|
||||
}
|
||||
|
||||
func readFull(ctx context.Context, fs *TorrentFS, t torrent.Torrent, off int64, p []byte) (n int, err error) {
|
||||
func readFull(ctx context.Context, fs *TorrentFS, t torrent.Download, off int64, p []byte) (n int, err error) {
|
||||
for len(p) != 0 {
|
||||
var nn int
|
||||
nn, err = blockingRead(ctx, fs, t, off, p)
|
||||
|
@ -225,7 +225,7 @@ func (dn dirNode) Attr(ctx context.Context, attr *fuse.Attr) error {
|
|||
func (me rootNode) Lookup(ctx context.Context, name string) (_node fusefs.Node, err error) {
|
||||
for _, t := range me.fs.Client.Torrents() {
|
||||
info := t.Info()
|
||||
if t.Name() != name || info == nil {
|
||||
if t.Info().Name != name || info == nil {
|
||||
continue
|
||||
}
|
||||
__node := node{
|
||||
|
|
Loading…
Reference in New Issue