void put(final URI uri, ArtifactData data) throws Exception { reporter.trace("put %s %s", uri, data); File tmp = createTempFile(repoDir, "mtp", ".whatever"); tmp.deleteOnExit(); try { copy(uri.toURL(), tmp); byte[] sha = SHA1.digest(tmp).digest(); reporter.trace("SHA %s %s", uri, Hex.toHexString(sha)); ArtifactData existing = get(sha); if (existing != null) { reporter.trace("existing"); xcopy(existing, data); return; } File meta = new File(repoDir, Hex.toHexString(sha) + ".json"); File file = new File(repoDir, Hex.toHexString(sha)); rename(tmp, file); reporter.trace("file %s", file); data.file = file.getAbsolutePath(); data.sha = sha; data.busy = false; CommandData cmddata = parseCommandData(data); if (cmddata.bsn != null) { data.name = cmddata.bsn + "-" + cmddata.version; } else data.name = Strings.display(cmddata.title, cmddata.bsn, cmddata.name, uri); codec.enc().to(meta).put(data); reporter.trace("TD = " + data); } finally { tmp.delete(); reporter.trace("puted %s %s", uri, data); } }
// remove temp files, the pipeline.jar operator isn't working. public void deleteTempFiles() { System.out.println("\nRemoving these temp files:"); File workingDir = new File(System.getProperty("user.dir")); File[] toExamine = workingDir.listFiles(); for (File f : toExamine) { boolean d = false; String n = f.getName(); if (n.startsWith("pipeinstancelog")) d = true; else if (n.contains(".DOC.sample")) d = true; else if (n.contains("allDepths.")) d = true; else if (n.startsWith("nocalls.")) d = true; else if (n.startsWith("snpeff.")) d = true; else if (n.contains("plice")) d = true; if (d) { System.out.println("\t" + n); f.deleteOnExit(); } } // delete the temp uncompressed vcf (required by Pipeline.jar) if (deleteTempVcf) System.out.println("\t" + finalVcf.getName()); }