Skip to content

Commit

Permalink
🐛 fix(github_utils): 修复路径解析问题 (#1668)
Browse files Browse the repository at this point in the history
* 🐛 fix(github_utils): 修复路径解析问题

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

---------

Co-authored-by: AkashiCoin <[email protected]>
  • Loading branch information
AkashiCoin and AkashiCoin authored Oct 2, 2024
1 parent 482eb1a commit d3a4a5b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion __version__
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__: v0.2.3
__version__: v0.2.3-a39d7a3
2 changes: 1 addition & 1 deletion zhenxun/utils/github_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion zhenxun/utils/github_utils/func.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
10 changes: 6 additions & 4 deletions zhenxun/utils/github_utils/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
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,
Expand Down Expand Up @@ -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
Expand All @@ -229,4 +231,4 @@ async def parse_repo_info(cls, repo_info: RepoInfo) -> "TreeInfo":

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)

0 comments on commit d3a4a5b

Please sign in to comment.