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

29
LINES

< > TinyBrain | #1008031 - loadDataSnippetToFile

JavaX fragment (include)

static File loadDataSnippetToFile(S snippetID) ctex {
  snippetID = fsI(snippetID);
  File f = DiskSnippetCache_file(parseSnippetID(snippetID));
  new L<URL> urlsTried;
  new L<Throwable> errors;
  try {
    URL url = addAndReturn(urlsTried, new URL(dataSnippetLink(snippetID)));
    print("Loading library: " + hideCredentials(url));
    try {
      loadBinaryPageToFile(openConnection(url), f);
      if (fileSize(f) == 0) fail();
    } catch e {
      errors.add(e);
      url = addAndReturn(urlsTried, new URL("http://data.tinybrain.de/blobs/"
        + psI(snippetID)));
      print("Trying other server: " + hideCredentials(url));
      loadBinaryPageToFile(openConnection(url), f);
      print("Got bytes: " + fileSize(f));
    }
    // TODO: check if we hit the "LOADING" message
    if (fileSize(f) == 0) fail();
    System.err.println("Bytes loaded: " + fileSize(f));
  } catch e {
    printStackTrace(e);
    errors.add(e);
    fail("Binary snippet " + snippetID + " not found or not public. URLs tried: " + allToString(urlsTried) + ", errors: " + allToString(errors));
  }
  return f;
}

Author comment

Began life as a copy of #1000675

download  show line numbers  debug dex   

Travelled to 4 computer(s): cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, tvejysmllsmz

No comments. add comment

Snippet ID: #1008031
Snippet name: loadDataSnippetToFile
Eternal ID of this version: #1008031/22
Text MD5: 5aac05896643e8c56529c4e046fcfad7
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-06 09:57:48
Source code size: 1126 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 160 / 162
Version history: 21 change(s)
Referenced in: [show]