| 1 | sbool serverMechList_raw_fresh_verbose; | 
| 2 | |
| 3 | static S serverMechList_raw_fresh(S name) {
 | 
| 4 | ret serverMechList_raw_fresh(name, false); | 
| 5 | } | 
| 6 | |
| 7 | static S serverMechList_raw_fresh(S name, bool opt) {
 | 
| 8 | lock downloadLock(); | 
| 9 | /*if (serverMechList_raw_fresh_verbose) | 
| 10 |     print("serverMechList_raw_fresh " + name);*/
 | 
| 11 | S text = null; | 
| 12 |   pcall { text = loadTextFile(remoteMechListMirrorFile(name)); }
 | 
| 13 | O[] params = muricaCredentialsPlus(md5 := md5OrNull(text), l := l(text), opt := opt ? 1 : 0, withStatus := 1); | 
| 14 | S url = "http://butter.botcompany.de:8080/mech/raw/list-text/" + urlencode(name); | 
| 15 | S page = postPageSilently(url, params); | 
| 16 | Map map = jsonDecodeMap(page); | 
| 17 |   bool same = eq(map.get("Same"), true);
 | 
| 18 |   bool appended = eq(map.get("Appended"), true);
 | 
| 19 | saveTextFile(remoteMechListMirrorMetaFile(name), struct(getMultipleKeys(map, "Name", "Status"))); | 
| 20 |   if (!same) {
 | 
| 21 |     if (appended) text += (S) map.get("Text");
 | 
| 22 |     else text = (S) map.get("Text");
 | 
| 23 | saveTextFile(remoteMechListMirrorFile(name), text); | 
| 24 | File nameFile = remoteMechListMirrorNameFile(name); | 
| 25 |     if (!fileExists(nameFile)) {
 | 
| 26 |       S actualName = or((S) map.get("Name"), name);
 | 
| 27 | saveTextFile(nameFile, actualName); | 
| 28 | } | 
| 29 | } | 
| 30 | if (serverMechList_raw_fresh_verbose) | 
| 31 |     print("Mech list " + name + ": " + (appended ? "appended" : same ? "same" : "downloaded") + ": " + n2(countLines(text), "line"));
 | 
| 32 |   if (!same) vmBus_send('remoteMechListMirrorChanged, name);
 | 
| 33 | ret text; | 
| 34 | } | 
Began life as a copy of #1014030
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1016015 | 
| Snippet name: | serverMechList_raw_fresh | 
| Eternal ID of this version: | #1016015/25 | 
| Text MD5: | a8821f0f8f8b8afe90ff8dfa2723ccbb | 
| Author: | stefan | 
| Category: | javax / a.i. | 
| Type: | JavaX fragment (include) | 
| Public (visible to everyone): | Yes | 
| Archived (hidden from active list): | No | 
| Created/modified: | 2019-02-06 13:15:09 | 
| Source code size: | 1474 bytes / 34 lines | 
| Pitched / IR pitched: | No / No | 
| Views / Downloads: | 739 / 827 | 
| Version history: | 24 change(s) | 
| Referenced in: | [show references] |