Skip to content

Commit

Permalink
fix: warning
Browse files Browse the repository at this point in the history
  • Loading branch information
ido-pluto committed Feb 26, 2024
1 parent 4a7f068 commit 63a6e23
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import {downloadFileBrowser} from "ipull/dist/browser.js";

const downloader = await downloadFileBrowser({
url: 'https://example.com/file.large',
acceptRangeAlwaysTrue: true // cors origin request will not return the range header, but we can force it to be true (multipart download)
acceptRangeAlwaysTrue: true // cors origin request will not return the range header, but we can force it to be true (multi-connection download)
});

await downloader.download();
Expand Down Expand Up @@ -227,7 +227,7 @@ interface DownloadEngineEvents {
start: [];
paused: [];
resumed: [];
progress: [ProgressStatusFile];
progress: [TransferProgressWithStatus];
save: [DownloadProgressInfo];
finished: [];
closed: [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ export default class DownloadEngineBrowser<WriteStream extends BaseDownloadEngin
file: downloadFile
});

if (options.acceptRangeIsKnown == null) {
const doesNotAcceptRange = downloadFile.parts.find(p => !p.acceptRange);
if (doesNotAcceptRange) {
console.warn(`Server does not accept range requests for "${doesNotAcceptRange.downloadURL}". Meaning fast-downloads/pausing/resuming will not work.

Check warning on line 73 in src/download/download-engine/engine/download-engine-browser.ts

View workflow job for this annotation

GitHub Actions / test

This line has a length of 163. Maximum allowed is 140
This may be related to cors origin policy (range header is ignored in the browser).
If you know the server accepts range requests, you can set "acceptRangeIsKnown" to true. To dismiss this warning, set "acceptRangeIsKnown" to false.`);

Check warning on line 75 in src/download/download-engine/engine/download-engine-browser.ts

View workflow job for this annotation

GitHub Actions / test

This line has a length of 151. Maximum allowed is 140
}
}

const allOptions: DownloadEngineOptionsBrowserConstructor = {...options, writeStream};
const engine = new DownloadEngineFile(downloadFile, allOptions);
return new DownloadEngineBrowser(engine, allOptions);
Expand Down

0 comments on commit 63a6e23

Please sign in to comment.