|
|
@ -57,15 +57,16 @@ class File { |
|
|
|
// Emit a download.start event with the url and filepath
|
|
|
|
emitter.emit('download.start', { url: this.url, filepath: this.filepath }); |
|
|
|
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
// Handle file errors
|
|
|
|
file.on('error', (err) => { |
|
|
|
fs.unlink(filepath, () => { |
|
|
|
// Emit a download.error event with the error
|
|
|
|
emitter.emit('download.error', { url: this.url, filepath: this.filepath, error: err.message, type: 'file' }); |
|
|
|
}); |
|
|
|
return reject(err.message); |
|
|
|
}); |
|
|
|
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
request |
|
|
|
.get(url.href, (response) => { |
|
|
|
// Check if response is valid
|
|
|
|