Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

34
LINES

< > BotCompany Repo | #1016015 // serverMechList_raw_fresh

JavaX fragment (include)

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;
}

Author comment

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: 507 / 581
Version history: 24 change(s)
Referenced in: [show references]