sbool serverMechList_raw_fresh_verbose; static S serverMechList_raw_fresh(S name) { ret serverMechList_raw_fresh(name, false); } static S serverMechList_raw_fresh(S name, bool opt) { lock downloadLock(); /*if (serverMechList_raw_fresh_verbose) print("serverMechList_raw_fresh " + name);*/ S text = null; pcall { text = loadTextFile(remoteMechListMirrorFile(name)); } O[] params = muricaCredentialsPlus(md5 := md5OrNull(text), l := l(text), opt := opt ? 1 : 0, withStatus := 1); S url = "http://butter.botcompany.de:8080/mech/raw/list-text/" + urlencode(name); S page = postPageSilently(url, params); Map map = jsonDecodeMap(page); bool same = eq(map.get("Same"), true); bool appended = eq(map.get("Appended"), true); saveTextFile(remoteMechListMirrorMetaFile(name), struct(getMultipleKeys(map, "Name", "Status"))); if (!same) { if (appended) text += (S) map.get("Text"); else text = (S) map.get("Text"); saveTextFile(remoteMechListMirrorFile(name), text); File nameFile = remoteMechListMirrorNameFile(name); if (!fileExists(nameFile)) { S actualName = or((S) map.get("Name"), name); saveTextFile(nameFile, actualName); } } if (serverMechList_raw_fresh_verbose) print("Mech list " + name + ": " + (appended ? "appended" : same ? "same" : "downloaded") + ": " + n2(countLines(text), "line")); if (!same) vmBus_send('remoteMechListMirrorChanged, name); ret text; }