From 3ec1ba853d8fe13ef922325603997aea67b47cd8 Mon Sep 17 00:00:00 2001
From: wxy1343 <1343890272@qq.com>
Date: Fri, 19 Nov 2021 13:32:56 +0800
Subject: [PATCH] [Fix] #64
---
README.md | 2 +-
aliyunpan/about.py | 2 +-
aliyunpan/api/core.py | 4 +++-
aliyunpan/cli/cli.py | 4 ++++
aliyunpan/exceptions.py | 7 +++++++
main.py | 4 ++--
6 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index 7207560..07c1760 100644
--- a/README.md
+++ b/README.md
@@ -334,7 +334,7 @@ python main.py COMMAND -h
自动刷新token间隔时间(秒) |
- change |
+ token |
--change, -c |
设置新的refresh_token |
diff --git a/aliyunpan/about.py b/aliyunpan/about.py
index a1c6124..a6950a3 100644
--- a/aliyunpan/about.py
+++ b/aliyunpan/about.py
@@ -1 +1 @@
-__version__ = '2.10.1'
+__version__ = '2.10.2'
diff --git a/aliyunpan/api/core.py b/aliyunpan/api/core.py
index 73cad9f..8a1cc97 100644
--- a/aliyunpan/api/core.py
+++ b/aliyunpan/api/core.py
@@ -16,7 +16,7 @@
from aliyunpan.common import *
from aliyunpan.exceptions import InvalidRefreshToken, AliyunpanException, AliyunpanCode, LoginFailed, \
InvalidContentHash, UploadUrlExpired, UploadUrlFailedRefresh, PartNumberOverLimit, BadResponseCode, \
- PartNotSequential, InvalidExpiration, FileShareNotAllowed
+ PartNotSequential, InvalidExpiration, FileShareNotAllowed, InvalidParentFileId
__all__ = ['AliyunPan']
@@ -310,6 +310,8 @@ def upload_file(self, parent_file_id: str = 'root', path: str = None, upload_tim
:param ignore: 忽略上传失败的文件
:return:
"""
+ if not parent_file_id:
+ raise InvalidParentFileId
path = Path(path)
file_size = path.stat().st_size
file_name = path.name
diff --git a/aliyunpan/cli/cli.py b/aliyunpan/cli/cli.py
index 877eb95..90a71da 100644
--- a/aliyunpan/cli/cli.py
+++ b/aliyunpan/cli/cli.py
@@ -305,6 +305,8 @@ def upload(self, path, upload_path='root', timeout=10.0, retry=3, force=False, s
return self.upload_share(share_list, upload_path, force)
else:
parent_file_id = self._path_list.get_path_fid(upload_path, update=False)
+ if not parent_file_id:
+ raise FileNotFoundError(upload_path)
try:
result = self._disk.upload_file(
parent_file_id=parent_file_id, path=str(path),
@@ -331,6 +333,8 @@ def upload(self, path, upload_path='root', timeout=10.0, retry=3, force=False, s
for file in upload_file_list:
try:
parent_file_id = self._path_list.get_path_fid(file[0], update=False)
+ if not parent_file_id:
+ raise FileNotFoundError(upload_path)
result = self._disk.upload_file(
parent_file_id=parent_file_id, path=file[1],
upload_timeout=timeout, retry_num=retry, force=force, chunk_size=chunk_size, c=c,
diff --git a/aliyunpan/exceptions.py b/aliyunpan/exceptions.py
index a6269c4..a0156ac 100644
--- a/aliyunpan/exceptions.py
+++ b/aliyunpan/exceptions.py
@@ -25,6 +25,13 @@ def __str__(self):
return self.message or 'Is not a valid access_token.'
+class InvalidParentFileId(AliyunpanException):
+ """无效的parent_file_id"""
+
+ def __str__(self):
+ return self.message or 'parent_file_id is not a valid value.'
+
+
class InvalidPassword(AliyunpanException):
"""无效的密码"""
diff --git a/main.py b/main.py
index 578e5f2..bac9ba0 100755
--- a/main.py
+++ b/main.py
@@ -122,7 +122,7 @@ def download(ctx, path, file, save_path, share, chunk_size, aria2):
if '=' in i:
kwargs[i.split('=')[0]] = i.split('=')[1]
else:
- kwargs[i] = True
+ kwargs[i.strip('-')] = True
commander.download(file_list, save_path=save_path, share=share, chunk_size=chunk_size, aria2=aria2, **kwargs)
@@ -186,7 +186,7 @@ def sync(ctx, local_path, remote_path, time_out, chunk_size, retry, sync_time, n
if '=' in i:
kwargs[i.split('=')[0]] = i.split('=')[1]
else:
- kwargs[i] = True
+ kwargs[i.strip('-')] = True
if local:
commander.sync_local(remote_path, local_path, sync_time, chunk_size, delete, **kwargs)
else: