Skip to content

A full-featured download manager.

fix: linux parse argv

Dr_rOotd4dab6de9b9f
diff --git a/package.json b/package.json
index 5d484837..fcb66ddb 100644
--- a/package.json
+++ b/package.json
@@ -131,7 +131,7 @@
"allowToChangeInstallationDirectory": true
},
"linux": {
- "category": "Network;Download;Utility",
+ "category": "Network",
"target": [
"deb",
"snap",
diff --git a/src/main/Application.js b/src/main/Application.js
index 1244c5e3..4c55241d 100644
--- a/src/main/Application.js
+++ b/src/main/Application.js
@@ -1,8 +1,9 @@
import { EventEmitter } from 'events'
import { app, shell, dialog, ipcMain } from 'electron'
import is from 'electron-is'
-import * as fs from 'fs'
+import { readFile } from 'fs'
import { extname, basename } from 'path'
+
import logger from './core/Logger'
import ConfigManager from './core/ConfigManager'
import { setupLocaleManager } from '@/ui/Locale'
@@ -163,7 +164,7 @@ export default class Application extends EventEmitter {
this.show()
const fileName = basename(filePath)
- fs.readFile(filePath, (err, data) => {
+ readFile(filePath, (err, data) => {
if (err) {
logger.warn(`[Motrix] read file error: ${filePath}`, err.message)
return
diff --git a/src/main/Launcher.js b/src/main/Launcher.js
index 78f6986b..78a945f3 100644
--- a/src/main/Launcher.js
+++ b/src/main/Launcher.js
@@ -33,8 +33,6 @@ export default class Launcher extends EventEmitter {
app.quit()
} else {
app.on('second-instance', (event, argv, workingDirectory) => {
- logger.warn('second-instance argv===>', argv)
- logger.warn('second-instance workingDirectory===>', workingDirectory)
global.application.showPage('index')
if (!is.macOS() && argv.length > 1) { // Windows, Linux
this.file = parseArgv(argv)
@@ -94,7 +92,6 @@ export default class Launcher extends EventEmitter {
this.sendFileToApplication()
})
} else if (process.argv.length > 1) { // Windows, Linux
- logger.warn('handleOpenFile argv===>', process.argv)
this.file = parseArgv(process.argv)
this.sendFileToApplication()
}
diff --git a/src/main/utils/index.js b/src/main/utils/index.js
index 5094ed6f..29bed0ce 100644
--- a/src/main/utils/index.js
+++ b/src/main/utils/index.js
@@ -65,11 +65,13 @@ export function isDirectory (path) {
}
export function parseArgv (argv) {
- logger.warn('parseArgv==111==>', argv)
- const arg = argv[1]
+ let arg = argv[1]
if (!arg || isDirectory(arg)) {
return
}
- logger.warn('parseArgv==222==>', arg)
- return resolve(arg)
+
+ if (is.linux()) {
+ arg = arg.replace('file://', '')
+ }
+ return arg
}