🐛 fix(github_utils): 修复路径解析问题 (#1668)

* 🐛 fix(github_utils): 修复路径解析问题

* chore(version): Update version to v0.2.3-a39d7a3

---------

Co-authored-by: AkashiCoin <AkashiCoin@users.noreply.github.com>
This commit is contained in:
AkashiCoin 2024-10-02 12:54:12 +08:00 committed by GitHub
parent 482eb1a214
commit d3a4a5bbf7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 9 additions and 7 deletions

View File

@ -1 +1 @@
__version__: v0.2.3
__version__: v0.2.3-a39d7a3

View File

@ -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

View File

@ -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,

View File

@ -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)