From d3a4a5bbf7502a7a987ecd8cfdc98b25a7a2bc84 Mon Sep 17 00:00:00 2001 From: AkashiCoin Date: Wed, 2 Oct 2024 12:54:12 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20fix(github=5Futils):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E8=B7=AF=E5=BE=84=E8=A7=A3=E6=9E=90=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#1668)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * :bug: fix(github_utils): 修复路径解析问题 * chore(version): Update version to v0.2.3-a39d7a3 --------- Co-authored-by: AkashiCoin --- __version__ | 2 +- zhenxun/utils/github_utils/__init__.py | 2 +- zhenxun/utils/github_utils/{consts.py => const.py} | 0 zhenxun/utils/github_utils/func.py | 2 +- zhenxun/utils/github_utils/models.py | 10 ++++++---- 5 files changed, 9 insertions(+), 7 deletions(-) rename zhenxun/utils/github_utils/{consts.py => const.py} (100%) diff --git a/__version__ b/__version__ index 6a49e381..a71fac09 100644 --- a/__version__ +++ b/__version__ @@ -1 +1 @@ -__version__: v0.2.3 +__version__: v0.2.3-a39d7a3 diff --git a/zhenxun/utils/github_utils/__init__.py b/zhenxun/utils/github_utils/__init__.py index 89b0a80a..eb1b047f 100644 --- a/zhenxun/utils/github_utils/__init__.py +++ b/zhenxun/utils/github_utils/__init__.py @@ -1,6 +1,6 @@ from collections.abc import Generator -from .consts import GITHUB_REPO_URL_PATTERN +from .const import GITHUB_REPO_URL_PATTERN from .func import get_fastest_raw_formats, get_fastest_archive_formats from .models import RepoAPI, RepoInfo, GitHubStrategy, JsdelivrStrategy diff --git a/zhenxun/utils/github_utils/consts.py b/zhenxun/utils/github_utils/const.py similarity index 100% rename from zhenxun/utils/github_utils/consts.py rename to zhenxun/utils/github_utils/const.py diff --git a/zhenxun/utils/github_utils/func.py b/zhenxun/utils/github_utils/func.py index 95d2a3ef..03c43182 100644 --- a/zhenxun/utils/github_utils/func.py +++ b/zhenxun/utils/github_utils/func.py @@ -1,7 +1,7 @@ from aiocache import cached from ..http_utils import AsyncHttpx -from .consts import ( +from .const import ( ARCHIVE_URL_FORMAT, RAW_CONTENT_FORMAT, RELEASE_ASSETS_FORMAT, diff --git a/zhenxun/utils/github_utils/models.py b/zhenxun/utils/github_utils/models.py index 17089281..a7bbad06 100644 --- a/zhenxun/utils/github_utils/models.py +++ b/zhenxun/utils/github_utils/models.py @@ -5,7 +5,7 @@ from strenum import StrEnum from pydantic import BaseModel from ..http_utils import AsyncHttpx -from .consts import CACHED_API_TTL, GIT_API_TREES_FORMAT, JSD_PACKAGE_API_FORMAT +from .const import CACHED_API_TTL, GIT_API_TREES_FORMAT, JSD_PACKAGE_API_FORMAT from .func import ( get_fastest_raw_formats, get_fastest_archive_formats, @@ -199,13 +199,15 @@ class GitHubStrategy: body: TreeInfo - def export_files(self, module_path: str) -> list[str]: + def export_files(self, module_path: str, is_dir: bool) -> list[str]: """导出文件路径""" tree_info = self.body return [ file.path for file in tree_info.tree - if file.type == TreeType.FILE and file.path.startswith(module_path) + if file.type == TreeType.FILE + and file.path.startswith(module_path) + and (not is_dir or file.path[len(module_path)] == "/") ] @classmethod @@ -229,4 +231,4 @@ class GitHubStrategy: def get_files(self, module_path: str, is_dir: bool = True) -> list[str]: """获取文件路径""" - return self.export_files(module_path) + return self.export_files(module_path, is_dir)