Comparing version 3.7.4 to 3.8.0
@@ -40,6 +40,18 @@ import { DownloadFile } from "../types.js"; | ||
/** | ||
* Abort the download & delete the file (if it exists) | ||
* Abort the download & delete the file (**even if** the download is finished) | ||
* @deprecated use `close` with flag `deleteFile` instead | ||
* | ||
* TODO: remove in the next major version | ||
*/ | ||
closeAndDeleteFile(): Promise<void>; | ||
/** | ||
* Close the download engine | ||
* @param deleteTempFile {boolean} - delete the temp file (when the download is **not finished**). | ||
* @param deleteFile {boolean} - delete the **temp** or **final file** (clean everything up). | ||
*/ | ||
close({ deleteTempFile, deleteFile }?: { | ||
deleteTempFile?: boolean; | ||
deleteFile?: boolean; | ||
}): Promise<void>; | ||
/** | ||
* Download/copy a file | ||
@@ -46,0 +58,0 @@ * |
@@ -10,2 +10,3 @@ import path from "path"; | ||
import filenamify from "filenamify"; | ||
import { DownloadStatus } from "../download-file/progress-status-file.js"; | ||
export const PROGRESS_FILE_EXTENSION = ".ipull"; | ||
@@ -68,10 +69,23 @@ /** | ||
/** | ||
* Abort the download & delete the file (if it exists) | ||
* Abort the download & delete the file (**even if** the download is finished) | ||
* @deprecated use `close` with flag `deleteFile` instead | ||
* | ||
* TODO: remove in the next major version | ||
*/ | ||
async closeAndDeleteFile() { | ||
await this.close(); | ||
try { | ||
await fs.unlink(this.fileAbsolutePath); | ||
await this.close({ deleteFile: true }); | ||
} | ||
/** | ||
* Close the download engine | ||
* @param deleteTempFile {boolean} - delete the temp file (when the download is **not finished**). | ||
* @param deleteFile {boolean} - delete the **temp** or **final file** (clean everything up). | ||
*/ | ||
async close({ deleteTempFile, deleteFile } = {}) { | ||
await super.close(); | ||
if (deleteFile || deleteTempFile && this.status.downloadStatus != DownloadStatus.Finished) { | ||
try { | ||
await fs.unlink(this.fileAbsolutePath); | ||
} | ||
catch { } | ||
} | ||
catch { } | ||
} | ||
@@ -78,0 +92,0 @@ /** |
{ | ||
"name": "ipull", | ||
"version": "3.7.4", | ||
"version": "3.8.0", | ||
"description": "The only file downloader you'll ever need. For node.js and the browser, CLI and library for fast and reliable file downloads.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
308837
4098