@vbarbarosh/node-helpers 3.24.1 → 3.25.0
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/package.json
CHANGED
package/src/errors/AbortError.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
const UserFriendlyError = require('./UserFriendlyError');
|
|
2
|
+
|
|
1
3
|
// https://github.com/nodejs/node/issues/36084#issuecomment-729894622
|
|
2
|
-
class AbortError extends
|
|
4
|
+
class AbortError extends UserFriendlyError
|
|
3
5
|
{
|
|
4
6
|
constructor(message = 'The operation was aborted') {
|
|
5
7
|
super(message);
|
package/src/fastdl.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const UserFriendlyError = require('./errors/UserFriendlyError');
|
|
1
2
|
const format_bytes = require('./format_bytes');
|
|
2
3
|
const format_progress = require('./format_progress');
|
|
3
4
|
const format_thousands = require('./format_thousands');
|
|
@@ -53,7 +54,7 @@ async function fastdl({file, read_stream_with_range, concurrency = 60, user_frie
|
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
if (total !== total_written) {
|
|
56
|
-
throw new
|
|
57
|
+
throw new UserFriendlyError(`Total bytes written differs from expected size of a file: total[${total}] - total_written[${total_written}] = ${total - total_written}`);
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
function spawn() {
|
|
@@ -73,7 +74,7 @@ async function fastdl({file, read_stream_with_range, concurrency = 60, user_frie
|
|
|
73
74
|
if (rs.content_range.total !== total) {
|
|
74
75
|
rs.once('error', ignore);
|
|
75
76
|
rs.destroy();
|
|
76
|
-
throw new
|
|
77
|
+
throw new UserFriendlyError('Size of a file changed during download');
|
|
77
78
|
}
|
|
78
79
|
const acc = new stream.PassThrough({
|
|
79
80
|
transform(buf, encoding, next) {
|