Refine search
public static void deleteDirectoryNoisily(File defaultDirectory) { if (!defaultDirectory.exists()) { return; } try { FileUtils.deleteDirectory(defaultDirectory); } catch (IOException e) { throw new RuntimeException("Failed to delete directory: " + defaultDirectory.getAbsolutePath(), e); } }
private void deletePomFolder(File finalPom) { if (finalPom != null) { File parentFile = new File(finalPom.getParent()); try { FileUtils.deleteDirectory(parentFile); } catch (IOException e) { } } }
/** * Backs up a directory <tt>dir</tt> by creating a .bak next to it. * * @param dir The directory to back up. */ public static void backupDirectory(File dir) throws IOException { File bak = new File(dir.getCanonicalPath() + ".bak"); if (bak.exists()) { FileUtils.deleteDirectory(bak); } dir.renameTo(bak); }
/** * Cleans up the installation by deleting the extracted module and downloaded installation folders */ public void clearPreviousInstall(String installDir) throws IOException { File installFolder = new File(installDir); // Remove installs from previous runs in the same folder if (installFolder.exists()) { logger.info("Deleting previous install folder " + installFolder.getAbsolutePath()); FileUtils.deleteDirectory(installFolder); } }
TmpFileSegmentWriteOutMedium(File outDir) throws IOException { File tmpOutputFilesDir = new File(outDir, "tmpOutputFiles"); FileUtils.forceMkdir(tmpOutputFilesDir); closer.register(() -> FileUtils.deleteDirectory(tmpOutputFilesDir)); this.dir = tmpOutputFilesDir; }
private void deleteTempDirectory(File tmpDirectory) throws IOException { if (tmpDirectory != null && tmpDirectory.exists()) { this.logger.debug("Deleting temporary directory {}", tmpDirectory); FileUtils.deleteDirectory(tmpDirectory); } }
private void cleanScreenshotsDirectory(DeviceResult.Builder result) throws IOException { File screenshotDir = new File(work, DEVICE_SCREENSHOT_DIR); if (screenshotDir.exists()) { imageDir.mkdirs(); handleImages(result, screenshotDir); FileUtils.deleteDirectory(screenshotDir); } }
public void cleanStorage() { logger.info("clean cache storage for path:" + cachePath); try { FileUtils.deleteDirectory(new File(cachePath)); } catch (IOException e) { logger.error("file delete fail:" + cachePath, e); } } }
/** * Clean up the directory. * * @param dir the directory to be deleted */ public static void cleanUpDir(final File dir) { try { if (dir != null && dir.exists()) { FileUtils.deleteDirectory(dir); } } catch (final IOException e) { logger.error("Failed to delete the directory", e); dir.deleteOnExit(); } }
private void cleanFilesDirectory(DeviceResult.Builder result) throws IOException { File testFilesDir = new File(work, DEVICE_FILE_DIR); if (testFilesDir.exists()) { fileDir.mkdirs(); handleFiles(result, testFilesDir); FileUtils.deleteDirectory(testFilesDir); } }
public static File createTestRootDiskStore(String testName) throws IOException { File diskDir = new File(testName).getAbsoluteFile(); FileUtils.deleteDirectory(diskDir); diskDir.mkdir(); diskDir.deleteOnExit(); return diskDir; }
/** * Deletes a file. If file is a directory, delete it and all sub-directories. * <p> * The difference between File.delete() and this method are: * <ul> * <li>A directory to be deleted does not have to be empty.</li> * <li>You get exceptions when a file or directory cannot be deleted. * (java.io.File methods returns a boolean)</li> * </ul> * * @param file file or directory to delete, must not be {@code null} * @throws NullPointerException if the directory is {@code null} * @throws FileNotFoundException if the file was not found * @throws IOException in case deletion is unsuccessful */ public static void forceDelete(final File file) throws IOException { if (file.isDirectory()) { deleteDirectory(file); } else { final boolean filePresent = file.exists(); if (!file.delete()) { if (!filePresent) { throw new FileNotFoundException("File does not exist: " + file); } final String message = "Unable to delete file: " + file; throw new IOException(message); } } }
private void cleanUpClusterWorkDirectory(String clusterId) throws IOException { final File appWorkDir = new File(GobblinClusterUtils.getAppWorkDirPath(this.clusterName, clusterId)); if (appWorkDir.exists() && appWorkDir.isDirectory()) { LOGGER.info("Deleting application working directory " + appWorkDir); FileUtils.deleteDirectory(appWorkDir); } }
public void uninstall(){ try { FileUtils.deleteDirectory(new File(getAbsolutePath())); } catch (IOException e) { e.printStackTrace(); } } }
private static void cleanupOutdatedEsData(EsInstallation esInstallation) { esInstallation.getOutdatedSearchDirectories().forEach(outdatedDir -> { if (outdatedDir.exists()) { LOG.info("Deleting outdated search index data directory {}", outdatedDir.getAbsolutePath()); try { FileUtils.deleteDirectory(outdatedDir); } catch (IOException e) { LOG.info("Failed to delete outdated search index data directory {}", outdatedDir.getAbsolutePath(), e); } } }); }
/** * Copies the container configuration (found through {@link #getConfiguration()}) to the logging * directory specified by {@link #logDir} */ public void cleanUp() throws IOException { File configDir = new File(getConfiguration().getHome()); if (configDir.exists()) { logger.info("Deleting configuration folder {}", configDir.getAbsolutePath()); FileUtils.deleteDirectory(configDir); } }
private void deleteExistingAssets(String pluginId) { LOGGER.info("Deleting cached static assets for plugin: {}", pluginId); try { FileUtils.deleteDirectory(new File(pluginStaticAssetsRootDir(pluginId))); if (pluginAssetPaths.containsKey(pluginId)) { pluginAssetPaths.remove(pluginId); } } catch (Exception e) { LOGGER.error("Failed to delete cached static assets for plugin: {}", pluginId, e); ExceptionUtils.bomb(e); } } }
public void init() throws IOException { if (localDir.exists()) { // TODO: We don't want some random jars of unknown provenance sitting around. Or do we care? // Ideally, we should try to reuse jars and verify using some checksum. FileUtils.deleteDirectory(localDir); } this.resourceDownloader = new ResourceDownloader(conf, localDir.getAbsolutePath()); workThread.start(); }
private boolean cleanDirectoryIfRepoChanged(File workingDirectory, ConsoleOutputStreamConsumer outputConsumer) { boolean cleaned = false; try { String p4RepoId = p4RepoId(); File file = new File(workingDirectory, ".cruise_p4repo"); if (!file.exists()) { FileUtils.writeStringToFile(file, p4RepoId, UTF_8); return true; } String existingRepoId = FileUtils.readFileToString(file, UTF_8); if (!p4RepoId.equals(existingRepoId)) { outputConsumer.stdOutput(format("[%s] Working directory has changed. Deleting and re-creating it.", GoConstants.PRODUCT_NAME)); FileUtils.deleteDirectory(workingDirectory); workingDirectory.mkdirs(); FileUtils.writeStringToFile(file, p4RepoId, UTF_8); cleaned = true; } return cleaned; } catch (IOException e) { throw bomb(e); } }
/** * @throws IOException If IO error happens. */ private void clearWorkDir() throws IOException { FileUtils.deleteDirectory(new File(WORK_DIR)); }