Comparing version 3.0.6 to 3.0.7
@@ -45,2 +45,3 @@ import ProgressStatusFile, { ProgressStatus } from "./progress-status-file.js"; | ||
get downloadSize(): number; | ||
get fileName(): string; | ||
get status(): ProgressStatus; | ||
@@ -47,0 +48,0 @@ protected get _activePart(): import("../types.js").DownloadFilePart; |
@@ -32,2 +32,5 @@ import ProgressStatusFile from "./progress-status-file.js"; | ||
} | ||
get fileName() { | ||
return this.file.localFileName; | ||
} | ||
get status() { | ||
@@ -34,0 +37,0 @@ return this._progressStatus.createStatus(this._progress.part + 1, this.transferredBytes); |
@@ -39,2 +39,3 @@ import { DownloadFile, SaveProgressInfo } from "../types.js"; | ||
get downloadSize(): number; | ||
get fileName(): string; | ||
get status(): import("../../transfer-visualize/format-transfer-status.js").FormattedStatus; | ||
@@ -41,0 +42,0 @@ get downloadStatues(): import("../../transfer-visualize/format-transfer-status.js").FormattedStatus[]; |
@@ -24,4 +24,7 @@ import UrlInputError from "./error/url-input-error.js"; | ||
get downloadSize() { | ||
return this._engine.file.totalSize; | ||
return this.file.totalSize; | ||
} | ||
get fileName() { | ||
return this.file.localFileName; | ||
} | ||
get status() { | ||
@@ -92,4 +95,5 @@ return this._latestStatus ?? createFormattedStatus(this._engine.status); | ||
}; | ||
let counter = 0; | ||
for (const part of parts) { | ||
const { length, acceptRange, newURL } = await fetchStream.fetchDownloadInfo(part); | ||
const { length, acceptRange, newURL, fileName } = await fetchStream.fetchDownloadInfo(part); | ||
const downloadURL = newURL ?? part; | ||
@@ -105,2 +109,5 @@ if (isNaN(length)) { | ||
}); | ||
if (counter++ === 0 && fileName) { | ||
downloadFile.localFileName = fileName; | ||
} | ||
} | ||
@@ -107,0 +114,0 @@ return downloadFile; |
@@ -9,2 +9,3 @@ import path from "path"; | ||
import fs from "fs-extra"; | ||
import filenamify from "filenamify"; | ||
export const PROGRESS_FILE_EXTENSION = ".ipull"; | ||
@@ -51,2 +52,3 @@ /** | ||
const downloadLocation = DownloadEngineNodejs._createDownloadLocation(downloadFile, options); | ||
downloadFile.localFileName = path.basename(downloadLocation); | ||
const writeStream = new DownloadEngineWriteStreamNodejs(downloadLocation + PROGRESS_FILE_EXTENSION, options); | ||
@@ -64,3 +66,3 @@ writeStream.fileSize = downloadFile.totalSize; | ||
const fileName = options.fileName || download.localFileName; | ||
return path.join(options.directory, fileName); | ||
return path.join(options.directory, filenamify(fileName)); | ||
} | ||
@@ -67,0 +69,0 @@ static _validateOptions(options) { |
@@ -21,2 +21,3 @@ import retry from "async-retry"; | ||
newURL?: string; | ||
fileName?: string; | ||
}; | ||
@@ -23,0 +24,0 @@ export type FetchSubState = { |
@@ -38,6 +38,9 @@ import BaseDownloadEngineFetchStream from "./base-download-engine-fetch-stream.js"; | ||
const acceptRange = this.options.acceptRangeIsKnown ?? response.headers.get("accept-ranges") === "bytes"; | ||
const fileName = response.headers.get("content-disposition") | ||
?.match(/filename="(.+)"/)?.[1]; | ||
return { | ||
length, | ||
acceptRange, | ||
newURL: response.url | ||
newURL: response.url, | ||
fileName | ||
}; | ||
@@ -44,0 +47,0 @@ } |
@@ -110,2 +110,4 @@ import BaseDownloadEngineFetchStream from "./base-download-engine-fetch-stream.js"; | ||
const length = xhr.getResponseHeader("Content-Length") || "-"; | ||
const fileName = xhr.getResponseHeader("content-disposition") | ||
?.match(/filename="(.+)"/)?.[1]; | ||
const acceptRange = this.options.acceptRangeIsKnown ?? xhr.getResponseHeader("Accept-Ranges") === "bytes"; | ||
@@ -115,3 +117,4 @@ resolve({ | ||
acceptRange, | ||
newURL: xhr.responseURL | ||
newURL: xhr.responseURL, | ||
fileName | ||
}); | ||
@@ -118,0 +121,0 @@ } |
@@ -48,2 +48,5 @@ import fs from "fs/promises"; | ||
async loadMetadataAfterFileWithoutRetry() { | ||
if (!await fsExtra.pathExists(this.path)) { | ||
return; | ||
} | ||
const fd = await this._ensureFileOpen(); | ||
@@ -50,0 +53,0 @@ const state = await fd.stat(); |
{ | ||
"name": "ipull", | ||
"version": "3.0.6", | ||
"version": "3.0.7", | ||
"description": "The only file downloader you'll ever need. For node.js and the browser, CLI and library for fast and reliable file downloads.", | ||
@@ -132,2 +132,3 @@ "main": "dist/index.js", | ||
"eventemitter3": "^5.0.1", | ||
"filenamify": "^6.0.0", | ||
"fs-extra": "^11.1.1", | ||
@@ -134,0 +135,0 @@ "is-unicode-supported": "^2.0.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
225233
2985
16
+ Addedfilenamify@^6.0.0
+ Addedfilename-reserved-regex@3.0.0(transitive)
+ Addedfilenamify@6.0.0(transitive)