Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

electron-dl-manager

Package Overview
Dependencies
Maintainers
0
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-dl-manager - npm Package Compare versions

Comparing version 3.2.0 to 3.2.1

4

dist/cjs/DownloadData.js

@@ -34,3 +34,5 @@ "use strict";

/**
* If true, the download was cancelled from the save as dialog
* If true, the download was cancelled from the save as dialog. This flag
* will also be true if the download was cancelled by the application when
* using the save as dialog.
*/

@@ -37,0 +39,0 @@ cancelledFromSaveAsDialog;

@@ -149,3 +149,3 @@ "use strict";

clearInterval(interval);
this.log("Download was cancelled by user");
this.log("Download was cancelled");
this.downloadData.cancelledFromSaveAsDialog = true;

@@ -152,0 +152,0 @@ await this.callbackDispatcher.onDownloadCancelled(this.downloadData);

@@ -31,3 +31,5 @@ import { generateRandomId } from "./utils";

/**
* If true, the download was cancelled from the save as dialog
* If true, the download was cancelled from the save as dialog. This flag
* will also be true if the download was cancelled by the application when
* using the save as dialog.
*/

@@ -34,0 +36,0 @@ cancelledFromSaveAsDialog;

@@ -123,3 +123,3 @@ import * as path from "node:path";

clearInterval(interval);
this.log("Download was cancelled by user");
this.log("Download was cancelled");
this.downloadData.cancelledFromSaveAsDialog = true;

@@ -126,0 +126,0 @@ await this.callbackDispatcher.onDownloadCancelled(this.downloadData);

@@ -31,3 +31,5 @@ import type { DownloadItem, Event, WebContents } from "electron";

/**
* If true, the download was cancelled from the save as dialog
* If true, the download was cancelled from the save as dialog. This flag
* will also be true if the download was cancelled by the application when
* using the save as dialog.
*/

@@ -34,0 +36,0 @@ cancelledFromSaveAsDialog?: boolean;

{
"name": "electron-dl-manager",
"version": "3.2.0",
"version": "3.2.1",
"description": "A library for implementing file downloads in Electron with 'save as' dialog and id support.",

@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js",

@@ -77,2 +77,3 @@ # Electron File Download Manager

- [Mock class](#mock-class)
- [FAQ](#faq)
- [Acknowledgments](#acknowledgments)

@@ -356,3 +357,5 @@

/**
* If true, the download was cancelled from the save as dialog
* If true, the download was cancelled from the save as dialog. This flag
* will also be true if the download was cancelled by the application when
* using the save as dialog.
*/

@@ -460,2 +463,47 @@ cancelledFromSaveAsDialog?: boolean

# FAQ
## How do I capture if the download is invalid? `onError()` is not being called.
Electron `DownloadItem` doesn't provide an explicit way to capture errors for downloads in general:
https://www.electronjs.org/docs/latest/api/download-item#class-downloaditem
(It only has `on('updated')` and `on('done')` events, which this library uses for defining the callback handlers.)
What it does for invalid URLs, it will trigger the `onDownloadCancelled()` callback.
```typescript
const id = await manager.download({
window: mainWindow,
url: 'https://alkjsdflksjdflk.com/file.zip',
callbacks: {
onDownloadCancelled: async (...) => {
// Invalid download; this callback will be called
},
}
});
```
A better way to handle this is to check if the URL exists prior to the download yourself.
I couldn't find a library that I felt was reliable to include into this package,
so it's best you find a library that works for you:
- https://www.npmjs.com/search?q=url%20exists&ranking=maintenance
GPT also suggests the following code (untested):
```typescript
async function urlExists(url: string): Promise<boolean> {
try {
const response = await fetch(url, { method: 'HEAD' });
return response.ok;
} catch (error) {
return false;
}
}
const exists = await urlExists('https://example.com/file.jpg');
```
# Acknowledgments

@@ -462,0 +510,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 too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc