public TempDir createTempDir() { return createTempDir(Thread.currentThread().getName()+"_"); }
public TempFile createTempFile() { return createTempFile("tmp"); }
@Override public void close() { deleteFilesIfExistsRecursively(path); } }
@Inject public TempFileManagerProvider(Config systemConfig) { Path dir = systemConfig.getOptional("tmpdir", String.class) .transform(s -> Paths.get(s)) .or(() -> { try { return Files.createTempDirectory("digdag-tempdir"); } catch (IOException ex) { throw Throwables.propagate(ex); } }); this.manager = new TempFileManager(dir); }
public TempFile createTempFile(String suffix) { return createTempFile(Thread.currentThread().getName()+"_", suffix); }
private TempDir createNewWorkspace(TaskRequest request) throws IOException { // prefix: {projectId}_{workflowName}_{attemptId}_{taskId} final String workspacePrefix = new StringBuilder() .append(request.getProjectId()).append("_") .append(request.getWorkflowName()).append("_") // workflow name is normalized before it's submitted. .append(request.getAttemptId()).append("_") .append(request.getTaskId()) .toString(); return tempFiles.createTempDir("workspace", workspacePrefix); } }
@Override public void close() { deleteFilesIfExistsRecursively(path); } }
private void openCurrentFile() throws IOException { if (currentFile == null) { synchronized (this) { if (currentFile == null) { if (closed) { throw new IOException("Task logger is already closed"); } currentFile = new CountingLogOutputStream( tempFiles.createTempFile("logs", tempFilePrefix, ".log.gz").get() ); } } } }
private ArchiveMetadata readArchiveMetadata(InputStream in, String projectName) throws IOException { Preconditions.checkArgument(!Strings.isNullOrEmpty(projectName), "projectName"); try (TempDir dir = tempFiles.createTempDir("push", projectName)) { long totalSize = 0; try (TarArchiveInputStream archive = new TarArchiveInputStream(new GzipCompressorInputStream(new BufferedInputStream(in, 32*1024)))) { totalSize = extractConfigFiles(dir.get(), archive); } if (totalSize > ARCHIVE_TOTAL_SIZE_LIMIT) { throw new IllegalArgumentException(String.format(ENGLISH, "Total size of the archive exceeds limit (%d > %d bytes)", totalSize, ARCHIVE_TOTAL_SIZE_LIMIT)); } ProjectArchive archive = projectArchiveLoader.load(dir.get(), WorkflowResourceMatcher.defaultMatcher(), cf.create()); return archive.getArchiveMetadata(); } }
try (TempFile tempFile = tempFiles.createTempFile("upload-", ".tar.gz")) {