| 20 | } |
| 21 | |
| 22 | bool OpdsServerStore::loadFromFile() { |
| 23 | if (Storage.exists(OPDS_FILE_JSON)) { |
| 24 | String json = Storage.readFile(OPDS_FILE_JSON); |
| 25 | if (!json.isEmpty()) { |
| 26 | // resave flag is set when passwords were stored in plaintext and need re-obfuscation |
| 27 | bool resave = false; |
| 28 | bool result = JsonSettingsIO::loadOpds(*this, json.c_str(), &resave); |
| 29 | if (result && resave) { |
| 30 | LOG_DBG("OPS", "Resaving JSON with obfuscated passwords"); |
| 31 | saveToFile(); |
| 32 | } |
| 33 | return result; |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | // No opds.json found — attempt one-time migration from the legacy single-server |
| 38 | // fields in CrossPointSettings (opdsServerUrl/opdsUsername/opdsPassword). |
| 39 | if (migrateFromSettings()) { |
| 40 | LOG_DBG("OPS", "Migrated legacy OPDS settings"); |
| 41 | return true; |
| 42 | } |
| 43 | |
| 44 | return false; |
| 45 | } |
| 46 | |
| 47 | bool OpdsServerStore::migrateFromSettings() { |
| 48 | if (strlen(SETTINGS.opdsServerUrl) == 0) { |