static File loadDataSnippetToFile(S snippetID) ctex { ifndef NoResourceLoader IResourceLoader rl = vm_getResourceLoader(); if (rl != null) ret rl.loadLibrary(snippetID); endifndef ret loadDataSnippetToFile_noResourceLoader(snippetID); } static File loadDataSnippetToFile_noResourceLoader(S snippetID) ctex { snippetID = fsI(snippetID); File f = DiskSnippetCache_file(parseSnippetID(snippetID)); new L urlsTried; new L 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(tb_mainServer() + "/blobs/" + psI(snippetID))); print(e); 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; }