()
| 55 | // ==================== Load / Save ==================== |
| 56 | |
| 57 | loadAll(): DataSource[] { |
| 58 | try { |
| 59 | const filePath = this.getConfigPath() |
| 60 | if (fs.existsSync(filePath)) { |
| 61 | const raw = fs.readFileSync(filePath, 'utf-8') |
| 62 | const parsed = JSON.parse(raw) |
| 63 | |
| 64 | if (!isValidDataSourceArray(parsed)) { |
| 65 | this.logger.warn('[DataSource] Incompatible config format detected, returning empty.') |
| 66 | return [] |
| 67 | } |
| 68 | |
| 69 | for (const ds of parsed) { |
| 70 | if (!ds.pullLimit) ds.pullLimit = 1000 |
| 71 | } |
| 72 | return parsed |
| 73 | } |
| 74 | } catch (err) { |
| 75 | this.logger.error('[DataSource] Failed to load config', err) |
| 76 | } |
| 77 | return [] |
| 78 | } |
| 79 | |
| 80 | private saveAll(sources: DataSource[]): void { |
| 81 | try { |
no test coverage detected