@torrent-tv/proxy 2.9.26 → 2.9.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/services/torrent-pool.js +21 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
## 2.9.27
|
|
2
|
+
|
|
3
|
+
- **Fix**: A magnet whose infoHash matches a torrent already loaded in the pool no longer fails with 500 "Cannot add duplicate torrent" (scenario: one viewer opened the .torrent file, another pasted the magnet of the same content — different source keys, one swarm). The duplicate-add error now resolves to the already-loaded torrent (waiting for its metadata when it is itself still cold), so both source keys share the swarm. Found by a field test of the magnet flow.
|
|
4
|
+
|
|
1
5
|
## 2.9.26
|
|
2
6
|
|
|
3
7
|
- **New**: Track inventory in the playback plan (OpenSpec change `track-selection`). The codec probe now parses EVERY input stream from the same ffmpeg banner, and the plan returns `audioTracks` and `subtitleTracks` — type-relative index, codec, language tag, `title` metadata, default disposition, and (for subtitles) a `textBased` flag (PGS/VobSub cannot become WebVTT).
|
package/package.json
CHANGED
package/services/torrent-pool.js
CHANGED
|
@@ -187,6 +187,27 @@ export class TorrentPool {
|
|
|
187
187
|
const promise = new Promise((resolve, reject) => {
|
|
188
188
|
const onError = (error) => {
|
|
189
189
|
this.client.off("error", onError);
|
|
190
|
+
// The same content can arrive as a .torrent AND as a magnet —
|
|
191
|
+
// different pool keys, one swarm. WebTorrent rejects the duplicate
|
|
192
|
+
// add; resolve with the already-loaded torrent instead of failing.
|
|
193
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
194
|
+
const dupMatch = /duplicate torrent ([0-9a-f]{40})/i.exec(message);
|
|
195
|
+
if (dupMatch) {
|
|
196
|
+
const existing = this.client.torrents.find((t) => t?.infoHash === dupMatch[1]);
|
|
197
|
+
if (existing) {
|
|
198
|
+
const settle = () => {
|
|
199
|
+
this.torrents.set(key, existing);
|
|
200
|
+
this.#pending.delete(key);
|
|
201
|
+
resolve(existing);
|
|
202
|
+
};
|
|
203
|
+
if (existing.ready) {
|
|
204
|
+
settle();
|
|
205
|
+
} else {
|
|
206
|
+
existing.once("ready", settle);
|
|
207
|
+
}
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
190
211
|
this.#pending.delete(key);
|
|
191
212
|
reject(error);
|
|
192
213
|
};
|