Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Lewis Salmon <jlsalmon@users.noreply.github.com>2022-03-27 22:41:08 +0300
committerGitHub <noreply@github.com>2022-03-27 22:41:08 +0300
commit5b4880aee559b4b8d294503039d07af98b09418c (patch)
tree4f91eb6df0b6f40df66f05a547cc206687164e8c
parent19699c4874be022d4ff0759d2b029e10152dcf53 (diff)
fix: web seed request URLs (#2267)
* fix: web seed request URLs When adding a multi torrent file (not magnet link) which has only web seeds, the torrent fails to download because webtorrent seems to try to call the wrong URL. Suppose that we are using the default download path of `/tmp/webtorrent`, and we have a web seed at `https://some-s3-bucket.s3.amazonaws.com/my-torrent` where `my-torrent` contains some nested directory structure like this: ``` my-torrent/ file1.txt file2/ file2.txt ``` Webtorrent will attempt to fetch the following URLs: ``` https://some-s3-bucket.s3.amazonaws.com/my-torrent//tmp/webtorrent/my-torrent/file1.txt https://some-s3-bucket.s3.amazonaws.com/my-torrent//tmp/webtorrent/my-torrent/file2/file2.txt ``` This is obviously incorrect, but perhaps I'm doing something wrong to cause this. I dug through the code, and it seems that `fs-chunk-store` is [modifying `file.path`](https://github.com/webtorrent/fs-chunk-store/blob/master/index.js#L48) when the [chunk store is created](https://github.com/webtorrent/webtorrent/blob/master/lib/torrent.js#L485). Stripping off the temp path fixes this issue and the download progresses as expected. * Update lib/webconn.js Co-authored-by: Diego Rodríguez Baquero <github@diegorbaquero.com> Co-authored-by: Diego Rodríguez Baquero <github@diegorbaquero.com>
-rw-r--r--lib/webconn.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/webconn.js b/lib/webconn.js
index bd306f6..b1170a6 100644
--- a/lib/webconn.js
+++ b/lib/webconn.js
@@ -102,7 +102,7 @@ class WebConn extends Wire {
const fileEnd = requestedFile.offset + requestedFile.length - 1
const url = this.url +
(this.url[this.url.length - 1] === '/' ? '' : '/') +
- requestedFile.path
+ requestedFile.path.replace(this._torrent.path, '')
return {
url,
fileOffsetInRange: Math.max(requestedFile.offset - rangeStart, 0),