Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
macos retry reopen torrent client (ledgerwatch#4645)
Browse files Browse the repository at this point in the history
* save

* save

* save

* save

* save

* save

* save

* save

* save
  • Loading branch information
AskAlexSharov committed Jul 6, 2022
1 parent 70bf7db commit f19101d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/downloader/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ func (d *Downloader) onComplete() {
panic(err)
}
d.cfg.DataDir = snapDir
// fmt.Printf("alex1: %s\n", d.cfg.DataDir)

db, c, m, torrentClient, err := openClient(d.cfg.ClientConfig)
if err != nil {
Expand Down Expand Up @@ -336,7 +335,14 @@ func openClient(cfg *torrent.ClientConfig) (db kv.RwDB, c storage.PieceCompletio
}
m = storage.NewMMapWithCompletion(snapDir, c)
cfg.DefaultStorage = m
torrentClient, err = torrent.NewClient(cfg)

for retry := 0; retry < 5; retry++ {
torrentClient, err = torrent.NewClient(cfg)
if err == nil {
break
}
time.Sleep(10 * time.Millisecond)
}
if err != nil {
return nil, nil, nil, nil, fmt.Errorf("torrent.NewClient: %w", err)
}
Expand Down

0 comments on commit f19101d

Please sign in to comment.