MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / loadFromFile

Method loadFromFile

src/OpdsServerStore.cpp:22–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20}
21
22bool 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
47bool OpdsServerStore::migrateFromSettings() {
48 if (strlen(SETTINGS.opdsServerUrl) == 0) {

Callers

nothing calls this directly

Calls 3

existsMethod · 0.80
readFileMethod · 0.80
isEmptyMethod · 0.45

Tested by

no test coverage detected