Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

后台运行机制代码存在bug #17

Closed
Nuaalzy opened this issue Jul 20, 2021 · 4 comments
Closed

后台运行机制代码存在bug #17

Nuaalzy opened this issue Jul 20, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@Nuaalzy
Copy link

Nuaalzy commented Jul 20, 2021

Client.py文件中,第77行判断是否有后台运行参数时,如果存在,立刻删除会导致后面数组访问越界,原始代码如下。

77 def init_command_line_parameter(self):
78 for k in range(len(sys.argv)):
79 if sys.argv[k] == '--resident' or sys.argv[k] == '-r':
80 DATA['config']['RESIDENT'] = True
81 del sys.argv[k]

报错情况为:
Traceback (most recent call last):
File "/root/aliyundrive-uploader-master/main.py", line 26, in
client.init_command_line_parameter()
File "/root/aliyundrive-uploader-master/Client.py", line 77, in init_command_line_parameter
if sys.argv[k] == '--resident' or sys.argv[k] == '-r':
IndexError: list index out of range

修改建议,增加标识位,for循环后再删除,如
label = -1
for k in range(len(sys.argv)):
if sys.argv[k] == '--resident' or sys.argv[k] == '-r':
DATA['config']['RESIDENT'] = True
label = k
if label>-1:
del sys.argv[label]

@aoaostar
Copy link
Owner

@Nuaalzy 已经修复了,感谢反馈

@Nuaalzy
Copy link
Author

Nuaalzy commented Jul 20, 2021

常驻运行仍然存在问题:
1.如果开启常驻运行,或者带-r参数时,不会添加新的任务,只会运行之前未完成添加到数据库的任务。只有在不开启常驻运行或者不带-r参数时才会添加任务。

main.py 第31行位置
https://github.com/Hidove/aliyundrive-uploader/blob/dd355e49d5f05394930f68d3a14aebc2747a9624/main.py#L31
if not DATA['config']['RESIDENT']:
for v in client.tasks:
tmp = DATA['task_template'].copy()
tmp.update({
"filepath": v,
"realpath": DATA['config']['FILE_PATH'] + v,
"create_time": get_timestamp(),
})
find = db.table('task').where('filepath=? and realpath=?', (tmp['filepath'], tmp['realpath'],)).find()
if find:
print_info('【%s】已存在任务队列中,跳过' % tmp['filepath'])
else:
create_task(tmp)

2.上传是会将配置文件中的网盘地址与上传文件或目录拼接为新地址,创建到网盘中去。例如,配置文件中设置上传目录为“网盘”,上传的文件目录为“目录一”,上传到网盘时会创建文件“网盘目录一”的文件,而不是放到网盘文件夹下。
main.py 第36行
https://github.com/Hidove/aliyundrive-uploader/blob/dd355e49d5f05394930f68d3a14aebc2747a9624/main.py#L36

@aoaostar
Copy link
Owner

1.这个我设定的就是这样的,以便于web端添加任务

2.这个是会将本地图片目录下的文件上传到网盘目录/图片目录下,上传单文件就是在网盘目录
https://github.com/Hidove/aliyundrive-uploader/blob/dd355e49d5f05394930f68d3a14aebc2747a9624/Client.py#L109

@Hidove Hidove closed this as completed Jul 22, 2021
@zsbai
Copy link

zsbai commented Jul 24, 2021

1.这个我设定的就是这样的,以便于web端添加任务

2.这个是会将本地图片目录下的文件上传到网盘目录/图片目录下,上传单文件就是在网盘目录

https://github.com/Hidove/aliyundrive-uploader/blob/dd355e49d5f05394930f68d3a14aebc2747a9624/Client.py#L109

使用宝塔插件的时候,需要上传/xxxx/path/下的文件,上传到网盘/1/,他会上传到网盘根目录,/1path/下,会创建一个1path的新文件夹

@Hidove Hidove reopened this Jul 25, 2021
@Hidove Hidove added the bug Something isn't working label Jul 25, 2021
@Hidove Hidove closed this as completed Jul 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants