projects
/
btrtrc.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
b8e03eb
)
cmd/torrent download: Handle interrupt when linear discarding
author
Matt Joiner <anacrolix@gmail.com>
Tue, 27 Feb 2024 12:22:07 +0000 (23:22 +1100)
committer
Matt Joiner <anacrolix@gmail.com>
Wed, 28 Feb 2024 04:47:38 +0000 (15:47 +1100)
cmd/torrent/download.go
patch
|
blob
|
history
diff --git
a/cmd/torrent/download.go
b/cmd/torrent/download.go
index 1fc4759f99f357cf9f5df69de14624bc9aa92bac..604820181dad5413084ec713272be892cb334119 100644
(file)
--- a/
cmd/torrent/download.go
+++ b/
cmd/torrent/download.go
@@
-171,10
+171,18
@@
func addTorrents(
defer wg.Done()
waitForPieces(ctx, t, 0, t.NumPieces())
}()
- if flags.LinearDiscard {
- r := t.NewReader()
- io.Copy(io.Discard, r)
- r.Close()
+ done := make(chan struct{})
+ go func() {
+ defer close(done)
+ if flags.LinearDiscard {
+ r := t.NewReader()
+ io.Copy(io.Discard, r)
+ r.Close()
+ }
+ }()
+ select {
+ case <-done:
+ case <-ctx.Done():
}
} else {
for _, f := range t.Files() {