t.maybeNewConns()
t.dataDownloadDisallowed.SetBool(spec.DisallowDataDownload)
t.dataUploadDisallowed = spec.DisallowDataUpload
- return errors.Join(t.AddPieceLayers(spec.PieceLayers)...)
+ return errors.Join(t.addPieceLayersLocked(spec.PieceLayers)...)
}
func (cl *Client) dropTorrent(t *Torrent, wg *sync.WaitGroup) (err error) {
}
}
-func (t *Torrent) AddPieceLayers(layers map[string]string) (errs []error) {
+func (t *Torrent) addPieceLayersLocked(layers map[string]string) (errs []error) {
if layers == nil {
return
}
return
}
+func (t *Torrent) AddPieceLayers(layers map[string]string) (errs []error) {
+ t.cl.lock()
+ defer t.cl.unlock()
+ return t.addPieceLayersLocked(layers)
+}
+
// Returns the index of the first file containing the piece. files must be
// ordered by offset.
func pieceFirstFileIndex(pieceOffset int64, files []*File) int {