@Override protected void cleanupInternal() { if (configFile != null) { if (!(configFile.delete())) { logger.warn("Unable to remove log file: " + configFile.getAbsolutePath()); } configFile = null; } if (dataPath != null) { if (!Files.forceDelete(dataPath)) { logger.warn("Unable to remove data dir: " + configFile.getAbsolutePath()); } } } }
@Override protected void deleteTempFiles() { super.deleteTempFiles(); if ((dbDir != null) && (dbDirIsTemp) && (!Files.forceDelete(dbDir))) { logger.warn("Could not delete temp db dir: {}", dbDir); } }
private void deleteFiles() { synchronized (fileToClean) { Map<File, Integer> copy = new HashMap<File, Integer>(fileToClean); for (File f : copy.keySet()) { try { Files.forceDelete(f.toPath()); fileToClean.remove(f); logger.info("Could delete " + f); } catch (IOException iox) { int newCounter = fileToClean.get(f) + 1; if (newCounter > MAX_RETRIES) { logger.error("Could not delete {} after {} retries, leave it unchanged", f, newCounter); fileToClean.remove(f); } else { fileToClean.put(f, newCounter); } } } } }
private void deleteFiles() { synchronized (fileToClean) { Map<File, Integer> copy = new HashMap<>(fileToClean); for (File f : copy.keySet()) { try { Files.forceDelete(f.toPath()); fileToClean.remove(f); logger.info("Could delete " + f); } catch (IOException iox) { int newCounter = fileToClean.get(f) + 1; if (newCounter > MAX_RETRIES) { logger.error("Could not delete {} after {} retries, leave it unchanged", f, newCounter); fileToClean.remove(f); } else { fileToClean.put(f, newCounter); } } } } }
public static boolean forceDelete(final File fileOrDir) { boolean ret = false; try { if ((fileOrDir != null) && (fileOrDir.exists())) { forceDelete(fileOrDir.toPath()); logger.debug("could delete {}", fileOrDir); ret = true; } } catch (IOException e) { logger.warn("could not delete {}. Will try to delete it again when program exits.", fileOrDir); FileCleaner.forceDeleteOnExit(fileOrDir); ret = true; } return ret; }
public static boolean forceDelete(final File fileOrDir) { boolean ret = false; try { if ((fileOrDir != null) && (fileOrDir.exists())) { forceDelete(fileOrDir.toPath()); logger.debug("could delete {}", fileOrDir); ret = true; } } catch (IOException e) { logger.warn("could not delete {}. Will try to delete it again when program exits.", fileOrDir); FileCleaner.forceDeleteOnExit(fileOrDir); ret = true; } return ret; }
public static void delete(ExtractedFileSet all) { for (File file : all.libraryFiles()) { if (file.exists() && !Files.forceDelete(file)) logger.warn("Could not delete {} NOW: {}", file); } File exe=all.executable(); if (exe.exists() && !Files.forceDelete(exe)) { logger.warn("Could not delete executable NOW: {}", exe); } if (all.baseDirIsGenerated()) { if (!Files.forceDelete(all.baseDir())) { logger.warn("Could not delete generatedBaseDir: {}", all.baseDir()); } } }
public static void delete(IExtractedFileSet all) { for (FileType type : EnumSet.complementOf(EnumSet.of(FileType.Executable))) { for (File file : all.files(type)) { if (file.exists() && !Files.forceDelete(file)) logger.warn("Could not delete {} NOW: {}", type, file); } } File exe=all.executable(); if (exe.exists() && !Files.forceDelete(exe)) { logger.warn("Could not delete executable NOW: {}", exe); } if (all.baseDirIsGenerated()) { if (!Files.forceDelete(all.baseDir())) { logger.warn("Could not delete generatedBaseDir: {}", all.baseDir()); } } }
@Override public synchronized final void stop() { if (!stopped) { stopped = true; stopInternal(); onAfterProcessStop(this.config, this.runtimeConfig); cleanupInternal(); if (!Files.forceDelete(pidFile)) { logger.warn("Could not delete pid file: {}", pidFile); } } }
@Override public synchronized final void stop() { if (!stopped) { stopped = true; stopInternal(); onAfterProcessStop(this.config, this.runtimeConfig); cleanupInternal(); if (!Files.forceDelete(pidFile)) { logger.warn("Could not delete pid file: {}", pidFile); } } }
protected void deleteTempFiles() { final Storage storage = getConfig().storage(); if (storage.dbDir() == null) { return; } if (!storage.isTmpDir()) { return; } if (!forceDelete(storage.dbDir())) { LOGGER.warn("Could not delete temp db dir: {}", storage.dbDir()); } }
protected final boolean sendStopToPostgresqlInstance() { final boolean result = shutdownPostgres(getConfig(), runtimeConfig); if (runtimeConfig.getArtifactStore() instanceof PostgresArtifactStore) { final IDirectory tempDir = ((PostgresArtifactStore) runtimeConfig.getArtifactStore()).getTempDir(); if (tempDir != null && tempDir.asFile() != null && tempDir.isGenerated()) { LOGGER.info("Cleaning up after the embedded process (removing {})...", tempDir.asFile().getAbsolutePath()); forceDelete(tempDir.asFile()); } } return result; }