Skip to content

Commit

Permalink
[Fix] #64
Browse files Browse the repository at this point in the history
  • Loading branch information
wxy1343 committed Nov 19, 2021
1 parent e4577bf commit 3ec1ba8
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ python main.py COMMAND -h
<td>自动刷新token间隔时间(秒)</td>
</tr>
<tr>
<td>change</td>
<td>token</td>
<td>--change, -c</td>
<td>设置新的refresh_token</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion aliyunpan/about.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.10.1'
__version__ = '2.10.2'
4 changes: 3 additions & 1 deletion aliyunpan/api/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions aliyunpan/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions aliyunpan/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""无效的密码"""

Expand Down
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 3ec1ba8

Please sign in to comment.