mirror of
https://github.com/everoddandeven/monerod-gui.git
synced 2024-12-22 11:39:25 +00:00
Fix uncaught permission exception on upgrade/install daemon casuing main process death #5
This commit is contained in:
parent
7a32bdc207
commit
546b810e3c
5 changed files with 46 additions and 2 deletions
14
app/main.ts
14
app/main.ts
|
@ -541,7 +541,19 @@ const downloadFile = (url: string, destinationDir: string, onProgress: (progress
|
|||
}
|
||||
|
||||
const destination = `${destinationDir}/${finalFilename}`;
|
||||
const file = fs.createWriteStream(destination);
|
||||
let file: fs.WriteStream;
|
||||
|
||||
try {
|
||||
file = fs.createWriteStream(destination);
|
||||
file.on('error', (error: Error) => {
|
||||
console.log("file error: " + error);
|
||||
reject(error);
|
||||
});
|
||||
}
|
||||
catch (error: any) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
|
||||
const totalBytes = parseInt(response.headers['content-length'] || '0', 10);
|
||||
let downloadedBytes = 0;
|
||||
|
|
|
@ -141,6 +141,14 @@ export class DaemonService {
|
|||
window.electronAPI.onMoneroClose((event: any, code: number) => {
|
||||
console.debug(event);
|
||||
console.debug(code);
|
||||
|
||||
if (code != 0) {
|
||||
window.electronAPI.showNotification({
|
||||
title: 'Daemon Error',
|
||||
body: 'Monero daemon exited with code: ' + code,
|
||||
closeButtonText: 'Dismiss'
|
||||
});
|
||||
}
|
||||
this.onClose();
|
||||
});
|
||||
|
||||
|
@ -220,6 +228,7 @@ export class DaemonService {
|
|||
|
||||
private onClose(): void {
|
||||
this.daemonRunning = false;
|
||||
this.starting = false;
|
||||
this.stopping = false;
|
||||
this.onDaemonStatusChanged.emit(false);
|
||||
this.onDaemonStopEnd.emit();
|
||||
|
|
11
src/app/core/utils/StringUtils.ts
Normal file
11
src/app/core/utils/StringUtils.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
export abstract class StringUtils {
|
||||
public static replaceAll(value: string, oldValue: string, newValue: string): string {
|
||||
let v = value;
|
||||
|
||||
while(v.includes(oldValue)) {
|
||||
v = v.replace(oldValue, newValue);
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
}
|
1
src/app/core/utils/index.ts
Normal file
1
src/app/core/utils/index.ts
Normal file
|
@ -0,0 +1 @@
|
|||
export { StringUtils } from "./StringUtils";
|
|
@ -5,6 +5,7 @@ import { SimpleBootstrapCard } from '../../shared/utils';
|
|||
import { DaemonVersion } from '../../../common/DaemonVersion';
|
||||
import { DaemonDataService, ElectronService, MoneroInstallerService } from '../../core/services';
|
||||
import { DaemonSettings } from '../../../common';
|
||||
import { StringUtils } from '../../core/utils';
|
||||
|
||||
@Component({
|
||||
selector: 'app-version',
|
||||
|
@ -165,7 +166,17 @@ export class VersionComponent implements AfterViewInit {
|
|||
|
||||
console.error(error);
|
||||
this.upgradeSuccess = false;
|
||||
this.upgradeError = `${error}`;
|
||||
let err = StringUtils.replaceAll(`${error}`, 'Error: ','');
|
||||
|
||||
if (err.includes('permission denied')) {
|
||||
const settings = await this.daemonService.getSettings();
|
||||
|
||||
this.upgradeError = 'Cannot download monerod to ' + settings.downloadUpgradePath;
|
||||
}
|
||||
else {
|
||||
this.upgradeError = err;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue