使用pkgs --update 下载解压zip文件是解析会出现错误
还没有人认领这个 Issue。
评估
调研方向
从 handle_zip_package 开始,检查如何使用 zipfile.ZipFile.namelist() 确定 package_folder_name,包括 Windows 路径转换。使用 pkgs --update 和 v2.5.0_for_rtthread.zip 重现该问题,然后验证解压路径和数据库路径包含完整的软件包内容,而不只是 .github/workflows/.
由索引模型根据 Issue 内容生成。
描述
例如:
解压v2.5.0_for_rtthread.zip 时找到的第一个文件是littlefs-refs-tags-v2.5.0_for_rtthread.github\workflows\下面的文件
def handle_zip_package 中
package_folder_name = os.path.split(right_path)[0]
package_folder_name 就成了littlefs-refs-tags-v2.5.0_for_rtthread.github\workflows
所以最终解压的内容经过cp就只有.github\workflows\ 下的文件
是否改成这样,找第一个item, 因为第一个itme永远是压缩包本身的文件夹
def handle_zip_package(archive_filename, bsp_package_path, package_name, package_info):
package_version = package_info['ver']
package_temp_path = os.path.join(bsp_package_path, "package_temp")
try:
if remove_folder(package_temp_path):
os.makedirs(package_temp_path)
except Exception as e:
logging.warning('Error message : {0}'.format(e))
logging.info("BSP packages path {0}".format(bsp_package_path))
logging.info("BSP package temp path: {0}".format(package_temp_path))
logging.info("archive filename : {0}".format(archive_filename))
try:
flag = True
package_folder_name = ""
package_name_with_version = ""
arch = zipfile.ZipFile(archive_filename, "r")
for item in arch.namelist():
arch.extract(item, package_temp_path)
if is_windows():
right_path = item.replace('/', '\\')
else:
right_path = item
# Gets the folder name and changed folder name only once
if flag:
package_folder_name = os.path.split(right_path)[0]
package_name_with_version = package_name + '-' + package_version
flag = False
if not os.path.isdir(os.path.join(package_temp_path, item)):
right_name_to_db = right_path.replace(package_folder_name, package_name_with_version, 1)
right_path = os.path.join("package_temp", right_path)
pkgsdb.save_to_database(right_name_to_db, archive_filename, right_path)
arch.close()
if not move_package_to_bsp_packages(package_folder_name, package_name, package_temp_path, package_version,
bsp_package_path):
return False
except Exception as e:
logging.warning('unpack error message : {0}'.format(e))
logging.warning('unpack {0} failed'.format(os.path.basename(archive_filename)))
# remove temp folder and archive file
remove_folder(package_temp_path)
os.remove(archive_filename)
return False
return True
- 主要语言
- Python
- 星标
- 78
- 派生
- 64
- 平均合并
- 1 天 6 小时
- 30 天内合并 PR
- 6
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
RT-Thread/env 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 68/100
-
难度 3/5 1-2 天 新手友好度 76/100
-
难度 4/5 3-5 天 新手友好度 35/100
-
难度 5/5 一周以上 新手友好度 30/100
-
改进 env 的文档未关闭
难度 4/5 3-5 天 新手友好度 38/100
相似的 Issue
-
comp/gateway comp/plugins duplicate P3 type/bug
难度 2/5 1-3 小时 新手友好度 82/100
NousResearch/hermes-agent#137019 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
bot-triaged module: docs triaged
难度 1/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
new-entry
难度 2/5 1-3 小时 新手友好度 78/100
BinWang28/audio-ai-hub#194 ·
-
confluence: a paged listing's links re-encode a parameter they carry, where real carries it as sent未关闭fidelity
难度 2/5 1-3 小时 新手友好度 63/100
维护者通常 1 天内回复