初始化安全更新器 Args: base_dir: 基础目录,默认为 sources/legado
(self, base_dir: Path = None)
| 42 | ] |
| 43 | |
| 44 | def __init__(self, base_dir: Path = None): |
| 45 | """ |
| 46 | 初始化安全更新器 |
| 47 | |
| 48 | Args: |
| 49 | base_dir: 基础目录,默认为 sources/legado |
| 50 | """ |
| 51 | self.base_dir = resolve_legado_dir(base_dir) |
| 52 | self.main_dir = self.base_dir / 'main' |
| 53 | self.backup_dir = self.main_dir / 'backups' |
| 54 | self.main_file = canonical_source_file(self.base_dir) |
| 55 | self.compatibility_file = compatibility_source_file(self.base_dir) |
| 56 | self.policy = SourcePolicy(self.base_dir.parent.parent) |
| 57 | |
| 58 | # 确保目录存在 |
| 59 | self.main_dir.mkdir(parents=True, exist_ok=True) |
| 60 | self.backup_dir.mkdir(parents=True, exist_ok=True) |
| 61 | |
| 62 | def validate_sources(self, sources: List[Dict]) -> Tuple[bool, str]: |
| 63 | """ |
nothing calls this directly
no test coverage detected