Skip to content

Commit

Permalink
cmd/torrent download: Handle interrupt when linear discarding
Browse files Browse the repository at this point in the history
  • Loading branch information
anacrolix committed Feb 28, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent b8e03eb commit edf59f0
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions cmd/torrent/download.go
Original file line number Diff line number Diff line change
@@ -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() {

0 comments on commit edf59f0

Please sign in to comment.