From 8019262c84c238606e8ddde3695438ed76100473 Mon Sep 17 00:00:00 2001 From: zhengwr Date: Thu, 29 Jan 2026 10:46:48 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=A7=92=E4=BC=A0?= =?UTF-8?q?=EF=BC=88instant=20upload=EF=BC=89=E5=9C=BA=E6=99=AF=E4=B8=8B?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 当文件哈希与服务器上已有文件匹配时,file/update/hash API 会返回 finish: true,表示文件已存在无需上传。原代码忽略了这个返回值, 继续尝试上传到 OSS,导致 NoSuchBucket 错误。 现在检查 hash_result.finish 字段,如果为 true 则直接返回成功。 Fixes: #1, #2, #6 Co-Authored-By: Claude Opus 4.5 --- quark_client/services/file_upload_service.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/quark_client/services/file_upload_service.py b/quark_client/services/file_upload_service.py index d30653c..eda66cf 100644 --- a/quark_client/services/file_upload_service.py +++ b/quark_client/services/file_upload_service.py @@ -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 单分片上传 From d756aa9026202549b916ab6c7e2e87e87706e43b Mon Sep 17 00:00:00 2001 From: zhengwr Date: Sat, 31 Jan 2026 15:40:03 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E6=94=AF=E6=8C=81=E7=9B=B8=E5=AF=B9?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 使用 file_path_obj.resolve() 将相对路径转换为绝对路径, 避免相对路径导致的异常行为 Co-Authored-By: Claude Opus 4.5 --- quark_client/cli/commands/basic_fileops.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quark_client/cli/commands/basic_fileops.py b/quark_client/cli/commands/basic_fileops.py index 287064a..bfaf4de 100644 --- a/quark_client/cli/commands/basic_fileops.py +++ b/quark_client/cli/commands/basic_fileops.py @@ -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 ) From 6d6de1f9bc370b6ee44ac7272ec9aff8a7aec549 Mon Sep 17 00:00:00 2001 From: zhengwr Date: Sat, 31 Jan 2026 21:45:40 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20cookie=20=E7=9B=AE=E5=BD=95=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=20~/.quarkpan=EF=BC=8C=E4=B8=8D=E5=8F=97=20cd=20?= =?UTF-8?q?=E5=BD=B1=E5=93=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 之前用 Path.cwd()/config,cd 后会找不到 cookie 导致要求重新登录 Co-Authored-By: Claude Opus 4.5 --- quark_client/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quark_client/config.py b/quark_client/config.py index 844f672..48df88e 100644 --- a/quark_client/config.py +++ b/quark_client/config.py @@ -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]: