mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-14 21:52:56 +08:00
🐛 fix(github_utils): 适配插件仓库根目录语法 (#1784)
This commit is contained in:
parent
4291cda244
commit
c84e99d084
@ -229,12 +229,15 @@ class ShopManage:
|
||||
continue
|
||||
else:
|
||||
raise ValueError("所有API获取插件文件失败,请检查网络连接")
|
||||
if module_path == ".":
|
||||
module_path = ""
|
||||
files = repo_api.get_files(
|
||||
module_path=module_path.replace(".", "/") + ("" if is_dir else ".py"),
|
||||
is_dir=is_dir,
|
||||
)
|
||||
download_urls = [await repo_info.get_raw_download_urls(file) for file in files]
|
||||
base_path = BASE_PATH / "plugins" if is_external else BASE_PATH
|
||||
base_path = base_path if module_path else base_path / repo_info.repo
|
||||
download_paths: list[Path | str] = [base_path / file for file in files]
|
||||
logger.debug(f"插件下载路径: {download_paths}", "插件管理")
|
||||
result = await AsyncHttpx.gather_download_file(download_urls, download_paths)
|
||||
|
||||
@ -106,8 +106,8 @@ class JsdelivrStrategy:
|
||||
def get_file_paths(self, module_path: str, is_dir: bool = True) -> list[str]:
|
||||
"""获取文件路径"""
|
||||
paths = module_path.split("/")
|
||||
filename = "" if is_dir else paths[-1]
|
||||
paths = paths if is_dir else paths[:-1]
|
||||
filename = "" if is_dir and module_path else paths[-1]
|
||||
paths = paths if is_dir and module_path else paths[:-1]
|
||||
cur_file = self.body
|
||||
for path in paths: # 导航到正确的目录
|
||||
cur_file = next(
|
||||
@ -141,7 +141,8 @@ class JsdelivrStrategy:
|
||||
]
|
||||
return []
|
||||
|
||||
return collect_files(cur_file, "/".join(paths), filename)
|
||||
files = collect_files(cur_file, "/".join(paths), filename)
|
||||
return files if module_path else [f[1:] for f in files]
|
||||
|
||||
@classmethod
|
||||
@cached(ttl=CACHED_API_TTL)
|
||||
@ -208,7 +209,7 @@ class GitHubStrategy:
|
||||
for file in tree_info.tree
|
||||
if file.type == TreeType.FILE
|
||||
and file.path.startswith(module_path)
|
||||
and (not is_dir or file.path[len(module_path)] == "/")
|
||||
and (not is_dir or file.path[len(module_path)] == "/" or not module_path)
|
||||
]
|
||||
|
||||
@classmethod
|
||||
|
||||
Loading…
Reference in New Issue
Block a user