Skip to content

Commit

Permalink
修复上传保存网盘目录异常的问题 (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
aoaostar committed Jul 25, 2021
1 parent 0f08da2 commit 1f3f221
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
9 changes: 4 additions & 5 deletions AliyunDrive.py
Expand Up @@ -33,7 +33,6 @@ def __init__(self, drive_id, root_path, chunk_size=10485760):
self.root_path = root_path
self.chunk_size = chunk_size
self.filepath = None
self.filepath_hash = None
self.realpath = None
self.filename = None
self.hash = None
Expand Down Expand Up @@ -148,8 +147,8 @@ def create(self, parent_file_id):
# 覆盖已有文件
if DATA['config']['OVERWRITE'] and requests_post_json.get('exist'):
if self.recycle(requests_post_json.get('file_id')):
self.print('【%s】原有文件回收成功' % self.filename, self.id, 'info')
self.print('【%s】重新上传新文件中' % self.filename, self.id, 'info')
self.print('【%s】原有文件回收成功' % self.filename, 'info')
self.print('【%s】重新上传新文件中' % self.filename, 'info')
return self.create(parent_file_id)

self.part_upload_url_list = requests_post_json.get('part_info_list', [])
Expand Down Expand Up @@ -317,6 +316,6 @@ def check_auth(self, response_json, func):
self.print('无法刷新AccessToken,准备退出', 'error')
sys.exit()

def print(self, message, type):
func = 'print_' + type
def print(self, message, print_type):
func = 'print_' + print_type
return getattr(common, func)(message, self.id)
3 changes: 2 additions & 1 deletion Client.py
Expand Up @@ -85,7 +85,7 @@ def init_command_line_parameter(self):
# 命令分配
if len(sys.argv) == 3:
# 网盘保存路径
DATA['config']['ROOT_PATH'] = qualify_path(sys.argv[2]).rstrip(os.sep)
DATA['config']['ROOT_PATH'] = sys.argv[2]
# 读取文件路径
abspath = os.path.abspath(sys.argv[1])

Expand All @@ -97,6 +97,7 @@ def init_command_line_parameter(self):
abspath = DATA['config']['FILE_PATH']

DATA['config']['FILE_PATH'] = os.path.dirname(abspath)
DATA['config']['ROOT_PATH'] = qualify_path(DATA['config']['FILE_PATH'])
if os.path.isdir(abspath):
# 目录上传
self.tasks = get_all_file_relative(abspath)
Expand Down
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -2,6 +2,7 @@

* Author:Pluto
* Github:https://github.com/Hidove/aliyundrive-uploader
* 宝塔插件:https://github.com/aoaostar/aliyundrive_uploader_for_baota

> 如有侵权,请联系我删除
>
Expand All @@ -13,6 +14,7 @@
## 使用方法
### 直接使用
<https://github.com/Hidove/aliyundrive-uploader/releases>

先下载对应系统版本,没有的需要自行编译
#### windows/Linux系统
* 下载文件后解压
Expand Down Expand Up @@ -123,6 +125,7 @@ git pull

## 编译
> 需要配合conda或virtualenv使用,请自行学习相关知识
> 也可使用actions里的自动编译
### 以virtualenv为例
* 安装virtualenv
Expand Down
5 changes: 1 addition & 4 deletions main.py
Expand Up @@ -42,9 +42,6 @@
else:
create_task(tmp)

if not DATA['config']['MULTITHREADING']:
DATA['config']['MAX_WORKERS'] = 1


def thread(task):
drive = client.upload_file(task)
Expand All @@ -56,7 +53,7 @@ def thread(task):


def distribute_thread(tasks):
if not DATA['config']['MULTITHREADING']:
if not DATA['config']['MULTITHREADING'] and DATA['config']['MAX_WORKERS'] <= 0:
for task in tasks:
thread(task)
else:
Expand Down

0 comments on commit 1f3f221

Please sign in to comment.