Add per-torrent ability to disable uploading
This commit is contained in:
parent
c7ea314de0
commit
d7627143bc
|
@ -1325,6 +1325,9 @@ func (c *PeerConn) uploadAllowed() bool {
|
|||
if c.t.cl.config.NoUpload {
|
||||
return false
|
||||
}
|
||||
if c.t.dataUploadDisallowed {
|
||||
return false
|
||||
}
|
||||
if c.t.seeding() {
|
||||
return true
|
||||
}
|
||||
|
|
24
torrent.go
24
torrent.go
|
@ -45,6 +45,7 @@ type Torrent struct {
|
|||
|
||||
networkingEnabled bool
|
||||
dataDownloadDisallowed bool
|
||||
dataUploadDisallowed bool
|
||||
userOnWriteChunkErr func(error)
|
||||
|
||||
// Determines what chunks to request from peers.
|
||||
|
@ -1273,6 +1274,9 @@ func (t *Torrent) seeding() bool {
|
|||
if t.closed.IsSet() {
|
||||
return false
|
||||
}
|
||||
if t.dataUploadDisallowed {
|
||||
return false
|
||||
}
|
||||
if cl.config.NoUpload {
|
||||
return false
|
||||
}
|
||||
|
@ -1969,6 +1973,26 @@ func (t *Torrent) AllowDataDownload() {
|
|||
|
||||
}
|
||||
|
||||
func (t *Torrent) AllowDataUpload() {
|
||||
t.cl.lock()
|
||||
defer t.cl.unlock()
|
||||
log.Printf("AllowDataUpload")
|
||||
t.dataUploadDisallowed = false
|
||||
for c := range t.conns {
|
||||
c.updateRequests()
|
||||
}
|
||||
}
|
||||
|
||||
func (t *Torrent) DisallowDataUpload() {
|
||||
t.cl.lock()
|
||||
defer t.cl.unlock()
|
||||
log.Printf("DisallowDataUpload")
|
||||
t.dataUploadDisallowed = true
|
||||
for c := range t.conns {
|
||||
c.updateRequests()
|
||||
}
|
||||
}
|
||||
|
||||
func (t *Torrent) SetOnWriteChunkError(f func(error)) {
|
||||
t.cl.lock()
|
||||
defer t.cl.unlock()
|
||||
|
|
Loading…
Reference in New Issue