Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions quark_client/cli/commands/basic_fileops.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,9 @@ def upload_file(file_path: str, parent_folder_id: str = "0", folder_path: Option
def progress_callback(percent: int, message: str):
progress.update(task, completed=percent, description=message)

# 开始上传
# 开始上传(使用绝对路径)
result = client.upload_file(
file_path=str(file_path),
file_path=str(file_path_obj.resolve()),
parent_folder_id=parent_folder_id,
progress_callback=progress_callback
)
Expand Down
4 changes: 2 additions & 2 deletions quark_client/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def get_config_dir() -> Path:
if config_dir:
return Path(config_dir)

# 默认使用当前目录下的config文件夹
return Path.cwd() / 'config'
# 默认使用用户主目录下的 .quarkpan 文件夹(不受 cd 影响)
return Path.home() / '.quarkpan'


def get_default_headers() -> Dict[str, str]:
Expand Down
17 changes: 16 additions & 1 deletion quark_client/services/file_upload_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,22 @@ def upload_file(
if progress_callback:
progress_callback(20, "更新文件哈希...")

self._update_file_hash(task_id, md5_hash, sha1_hash)
hash_result = self._update_file_hash(task_id, md5_hash, sha1_hash)

# 检查是否秒传成功(文件已存在于服务器)
if hash_result.get('finish'):
if progress_callback:
progress_callback(100, "秒传成功")
return {
'status': 'success',
'task_id': task_id,
'file_name': file_name,
'file_size': file_size,
'md5': md5_hash,
'sha1': sha1_hash,
'upload_result': {'strategy': 'instant_upload', 'message': '秒传成功,文件已存在'},
'finish_result': hash_result
}

# 步骤3: 根据文件大小选择上传策略
if file_size < 5 * 1024 * 1024: # < 5MB 单分片上传
Expand Down