Skip to content

Commit

Permalink
v1.4.2 - 修复无法保存未完成的任务的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Xmader committed Sep 26, 2018
1 parent 08019aa commit 483e170
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 23 deletions.
26 changes: 26 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"env": {
"es6": true,
"node": true,
"browser": true
},
"extends": "eslint:recommended",
"rules": {
"indent": [
"error",
4
],
"linebreak-style": [
"error",
"windows"
],
"quotes": [
"warn",
"double"
],
"semi": [
"warn",
"never"
]
}
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

* 集成aria2c
* 多线程下载
* 未完成任务退出自动保存
* 未完成任务退出自动保存 <!-- (Bug: 需要暂停才能保存进度) -->
* 支持PT/BT
* 下载完成消息通知
* 多语言支持
* 支持配置多个 aria2 RPC
* 支持直接从远程aria2服务器上下载文件
* 支持打开下载文件夹, 在文件管理器中显示已下载的文件 (仅限使用内置的Aria2 RPC)
* 使用响应式布局, 支持各种计算机或移动设备
* 友好的界面交互

Expand All @@ -43,7 +43,7 @@
* Download finished notification
* Multi-languages support
* Multi aria2 RPC host support
* Support for downloading files from a remote aria2 server directly
* Support for opening download folder, and displaying downloaded files in file manager (the built-in Aria2 RPC only)
* Responsive design, supporting desktop and mobile devices
* User-friendly interface

Expand Down
2 changes: 1 addition & 1 deletion app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ app.on('ready', function () {
const aria2_dir = path.join(__dirname, "aria2", platform, aria2_bin)

const conf_path = path.join(__dirname, "aria2", "aria2.conf")
edit_conf() // 根据用户的操作系统动态编辑aria2的配置文件
edit_conf(conf_path) // 根据用户的操作系统动态编辑aria2的配置文件

//打开主程序
fs.chmodSync(aria2_dir, 0o777)
Expand Down
8 changes: 4 additions & 4 deletions app/aria2/aria2.conf
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ check-certificate=false
## 进度保存相关 ##

# 从会话文件中读取下载任务
input-file=./resources/app/aria2/aria2.session
input-file=
# 在Aria2退出时保存错误的、未完成的下载任务到会话文件
save-session=./resources/app/aria2/aria2.session
save-session=
# 定时保存会话, 0为退出时才保存, 需1.16.1以上版本, 默认:0
save-session-interval=60
save-session-interval=5

## RPC相关设置 ##

Expand All @@ -58,7 +58,7 @@ rpc-listen-all=true
# RPC端口, 仅当默认端口被占用时修改
# rpc-listen-port=6900
# 设置的RPC授权令牌, v1.18.4新增功能, 取代 --rpc-user 和 --rpc-passwd 选项
#rpc-secret=xmader
#rpc-secret=
# 是否启用 RPC 服务的 SSL/TLS 加密,
# 启用加密后 RPC 服务需要使用 https 或者 wss 协议连接
rpc-secure=false
Expand Down
21 changes: 7 additions & 14 deletions app/edit_conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,16 @@ const fs = require('fs')
const path = require('path')
const { app } = require('electron')

const edit_conf = (conf_path = `${__dirname}/aria2/aria2.conf`) => {
const download_dir = app.getPath("downloads") || path.join(os.homedir(), "Downloads")
const download_dir = app.getPath("downloads") || path.join(os.homedir(), "Downloads")

let old_conf = fs.readFileSync(conf_path).toString()

let old_conf_list = old_conf.split("\r\n")
if (old_conf_list.length == 1) {
old_conf_list = old_conf.split("\n")
}
const edit_conf = (conf_path) => {
const session_path = path.join(path.dirname(conf_path), "aria2.session")

let new_conf_list = old_conf_list.map(x => {
if (x.startsWith("input-file=") || x.startsWith("save-session=")) return "# " + x
else if (x.startsWith("dir=")) return "dir=" + download_dir
else return x
})
let old_conf = fs.readFileSync(conf_path).toString()

let new_conf = new_conf_list.join("\n")
let new_conf = old_conf
.replace(/dir=.+/, "dir=" + download_dir)
.replace(/(input-file=|save-session=).*/g, "$1" + session_path)

fs.writeFileSync(conf_path, new_conf)
}
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ariang-gui",
"version": "1.4.1",
"version": "1.4.2",
"private": true,
"description": "AriaNg GUI",
"main": "app.js",
Expand Down

0 comments on commit 483e170

Please sign in to comment.