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