修复上传安装应用和从文件URL安装应用多了一层目录的问题
This commit is contained in:
parent
4209f45229
commit
60a8f3090e
@ -80,23 +80,16 @@ def analyze_package(temp_dir: str) -> Dict[str, Any]:
|
||||
if not root_items:
|
||||
return {'success': False, 'error': '目录为空'}
|
||||
|
||||
# 对于 git clone 的目录,跳过 .git,检查是否为应用根目录
|
||||
# 统计非 .git 的目录数量
|
||||
non_git_dirs = [item for item in root_items if os.path.isdir(os.path.join(temp_dir, item)) and item != '.git']
|
||||
|
||||
# 检查是否包含 .git 目录(说明是 Git 仓库)
|
||||
is_git_repo = '.git' in root_items
|
||||
# 对于解压后的目录,判断应用层级
|
||||
# 统计非系统目录的目录数量
|
||||
non_git_dirs = [item for item in root_items if os.path.isdir(os.path.join(temp_dir, item)) and item not in ['.git', '__pycache__']]
|
||||
|
||||
root_dir = temp_dir
|
||||
|
||||
# 如果只有一个目录且是 Git 仓库,通常是 Git 仓库克隆后的结构,需要进入
|
||||
# 如果有多个目录,说明已经是应用根目录
|
||||
if len(non_git_dirs) == 1 and is_git_repo:
|
||||
# 如果只有一个目录,需要进入(解压后的标准结构)
|
||||
if len(non_git_dirs) == 1:
|
||||
root_dir = os.path.join(temp_dir, non_git_dirs[0])
|
||||
# 如果多个目录但有 .git,说明 Git 仓库根目录就是应用根目录(典型开发结构)
|
||||
elif len(non_git_dirs) > 1 and is_git_repo:
|
||||
# 不进入子目录,直接使用 temp_dir 作为 root_dir
|
||||
root_dir = temp_dir
|
||||
# 如果有多个目录(demo/, frontend/ 等),说明已经是应用根目录,直接使用
|
||||
|
||||
package_info = {
|
||||
'app_name': os.path.basename(root_dir),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user