/** * Removes the repository completely, even with the .git directory */ public void forceClear() { try (DirectoryStream<Path> ds = Files.newDirectoryStream(this.repositoryRoot)) { for (Path p : ds) { FileUtils.forceDelete(p); } } catch (IOException e) { FilebasedRepository.LOGGER.error(e.getMessage()); } }
/** * Removes all files and dirs except the .git directory */ @Override public void doClear() { try { DirectoryStream.Filter<Path> noGitDirFilter = entry -> !(entry.getFileName().toString().equals(".git")); try (DirectoryStream<Path> ds = Files.newDirectoryStream(this.repositoryRoot, noGitDirFilter)) { for (Path p : ds) { FileUtils.forceDelete(p); } } } catch (IOException e) { FilebasedRepository.LOGGER.error(e.getMessage()); } }
@Override public void forceDelete(GenericId id) { FileUtils.forceDelete(this.id2AbsolutePath(id)); }
public static Path unzipFile(InputStream in) { Path dir = Utils.getTmpDir(Paths.get("zip")); FileUtils.forceDelete(dir); try (ZipInputStream inputStream = new ZipInputStream(in)) { ZipEntry entry; while (Objects.nonNull(entry = inputStream.getNextEntry())) { if (!entry.isDirectory()) { Path targetPath = dir.resolve(entry.getName()); Files.createDirectories(targetPath.getParent()); Files.copy(inputStream, targetPath); logger.debug("Write tmp file: {}", targetPath.toString()); } } } catch (Exception e) { logger.error("Create zip tmp file error: ", e); } return dir; }
} finally { FileUtils.forceDelete(csarDir);
public void forceDelete(Class<? extends DefinitionsChildId> definitionsChildIdClazz, Namespace namespace) { // instantiate new definitions child id with "ID" as id // this is used to get the absolute path DefinitionsChildId id = BackendUtils.getDefinitionsChildId(definitionsChildIdClazz, namespace.getEncoded(), "ID", true); Path path = this.id2AbsolutePath(id); // do not delete the id, delete the complete namespace // patrent folder is the namespace folder path = path.getParent(); FileUtils.forceDelete(path); }
FileUtils.forceDelete(workingDir);