修复CDN URL和路径构建逻辑

- 修复CDN URL构建,正确处理路径重复问题
- 修复rclone路径构建,使用正确的格式: {rclone_remote}:{storage_path}/{version_path}/{filename}
- 修复CDN路径构建,使用正确的格式: {cdn_base_url}/{version_path}/{filename}
- 修复CDN内容解密处理,支持加密和解密后的内容
- 添加路径构建测试示例
- 完善错误处理和空内容处理
This commit is contained in:
2025-08-07 18:03:16 +08:00
parent 4cb6c4eab7
commit 9eddb3133c
13 changed files with 675 additions and 32 deletions

View File

@@ -43,10 +43,72 @@ python main.py view --help
- `--version`: 版本号,格式为 0.29, 0.30, 0.31 等(必需)
- `--json`: 以JSON格式输出可选
- `--storage-path`: 对象存储路径前缀,默认为 'ab'(可选
- `--cdn-url`: CDN基础URL可选
- `--storage-path`: 对象存储路径前缀(覆盖配置文件
- `--cdn-url`: CDN基础URL覆盖配置文件
- `--mock`: 使用模拟环境进行测试(可选)
### 配置管理命令
- `show-config`: 显示当前配置
- `set-config`: 设置配置值
## 配置文件
Config-Man 支持多种配置方式:
### 1. 配置文件
默认配置文件位置:
- 用户配置: `~/.config/config-man/config-man.json`
- 项目配置: `./config-man.json`
配置文件格式:
```json
{
"storage": {
"path": "ab",
"rclone_remote": "remote",
"timeout": 30
},
"cdn": {
"base_url": "",
"timeout": 10,
"retry_count": 3
},
"crypto": {
"algorithm": "DES",
"key": "tbambooz"
},
"display": {
"table_format": "grid",
"max_width": 80,
"truncate_length": 25
}
}
```
### 2. 环境变量
支持以下环境变量:
| 环境变量 | 配置项 | 说明 |
|---------|--------|------|
| `CONFIG_MAN_STORAGE_PATH` | `storage.path` | 存储路径 |
| `CONFIG_MAN_STORAGE_RCLONE_REMOTE` | `storage.rclone_remote` | rclone远程名称 |
| `CONFIG_MAN_STORAGE_TIMEOUT` | `storage.timeout` | 存储操作超时时间 |
| `CONFIG_MAN_CDN_BASE_URL` | `cdn.base_url` | CDN基础URL |
| `CONFIG_MAN_CDN_TIMEOUT` | `cdn.timeout` | CDN请求超时时间 |
| `CONFIG_MAN_CDN_RETRY_COUNT` | `cdn.retry_count` | CDN重试次数 |
| `CONFIG_MAN_CRYPTO_KEY` | `crypto.key` | 加密密钥 |
| `CONFIG_MAN_CRYPTO_ALGORITHM` | `crypto.algorithm` | 加密算法 |
| `CONFIG_MAN_DISPLAY_TABLE_FORMAT` | `display.table_format` | 表格格式 |
| `CONFIG_MAN_DISPLAY_MAX_WIDTH` | `display.max_width` | 最大宽度 |
| `CONFIG_MAN_DISPLAY_TRUNCATE_LENGTH` | `display.truncate_length` | 截断长度 |
### 3. 命令行参数
命令行参数会覆盖配置文件和环境变量的设置。
## 输出格式
### 表格格式(默认)
@@ -146,16 +208,35 @@ python main.py view --version 0.30 --mock
## 高级用法
### 自定义存储路径
### 配置管理
```bash
python main.py view --version 0.30 --storage-path custom_path
# 显示当前配置
python main.py show-config
# 设置配置值
python main.py set-config --key storage.path --value custom_path
python main.py set-config --key cdn.base_url --value https://cdn.example.com
python main.py set-config --key display.max_width --value 100
```
### 指定CDN URL
### 环境变量配置
```bash
python main.py view --version 0.30 --cdn-url https://cdn.example.com
# 使用环境变量设置配置
export CONFIG_MAN_STORAGE_PATH=custom_path
export CONFIG_MAN_CDN_BASE_URL=https://cdn.example.com
export CONFIG_MAN_DISPLAY_MAX_WIDTH=120
# 运行命令
python main.py view --version 0.30
```
### 命令行参数覆盖
```bash
# 命令行参数会覆盖配置文件设置
python main.py view --version 0.30 --storage-path custom_path --cdn-url https://cdn.example.com
```
### 组合使用