Mercurial > hg > mercurial
changeset 845:07a3d55dda1b
Reuse utility method
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Wed, 25 Jun 2014 21:43:40 +0200 |
parents | a345056434a9 |
children | cea91fa66d3b |
files | mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgFileUtil.java |
diffstat | 1 files changed, 2 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgFileUtil.java Wed Jun 25 21:11:35 2014 +0200 +++ b/mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/HgFileUtil.java Wed Jun 25 21:43:40 2014 +0200 @@ -17,13 +17,12 @@ package jetbrains.buildServer.buildTriggers.vcs.mercurial; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.util.SystemInfo; import jetbrains.buildServer.util.FileUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import com.intellij.openapi.util.SystemInfo; import java.io.File; -import java.io.FileFilter; import java.io.IOException; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -94,38 +93,8 @@ public static void deleteDir(@Nullable final File dir, @NotNull final Logger logger) { if (dir == null) return; - final String dirPath; - try { - dirPath = dir.getCanonicalPath(); - } catch (IOException e) { - logger.warn("Cannot get canonical path " + dir.getAbsolutePath()); - return; - } - FileUtil.delete(dir, SystemInfo.isWindows ? new AcceptAll() : new AcceptOnlyChildren(dirPath), 10); + FileUtil.symlinkAwareDelete(dir); if (dir.exists()) logger.warn("Cannot delete directory " + dir.getAbsolutePath()); } - - private static class AcceptAll implements FileFilter { - public boolean accept(File pathname) { - return true; - } - } - - private static class AcceptOnlyChildren implements FileFilter { - private final String myRootDirPath; - - private AcceptOnlyChildren(@NotNull String rootDirPath) { - myRootDirPath = rootDirPath; - } - - public boolean accept(File pathname) { - try { - String childFilePath = pathname.getCanonicalPath(); - return childFilePath.startsWith(myRootDirPath); - } catch (IOException e) { - return false; - } - } - } }