From cbf064aacd869451e33701c861828bc574d800c3 Mon Sep 17 00:00:00 2001 From: Vasily Romanikhin Date: Fri, 8 May 2020 18:30:22 +0300 Subject: [PATCH] CPP-19906: Remote host sync silently hangs: recursive symlinks in header paths. GitOrigin-RevId: 3a59d2f6255fad010c3c0f16c72d0fa676788725 --- .../com/intellij/util/io/Decompressor.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/platform/util/src/com/intellij/util/io/Decompressor.java b/platform/util/src/com/intellij/util/io/Decompressor.java index c208d40ec296..fad1c186ed4d 100644 --- a/platform/util/src/com/intellij/util/io/Decompressor.java +++ b/platform/util/src/com/intellij/util/io/Decompressor.java @@ -205,6 +205,7 @@ public abstract class Decompressor { } @Nullable private Condition myFilter = null; + @Nullable private Condition myEntryFilter = null; @Nullable private List myPathsPrefix = null; private boolean myOverwrite = true; @Nullable private Consumer myConsumer; @@ -214,6 +215,11 @@ public abstract class Decompressor { return this; } + public Decompressor filterEntries(@Nullable Condition filter) { + myEntryFilter = filter; + return this; + } + public Decompressor overwrite(boolean overwrite) { myOverwrite = overwrite; return this; @@ -252,6 +258,10 @@ public abstract class Decompressor { } } + if (myEntryFilter != null && !myEntryFilter.value(entry)) { + continue; + } + if (myPathsPrefix != null) { entry = entry.mapPathPrefix(myPathsPrefix); if (entry == null) continue; @@ -308,14 +318,14 @@ public abstract class Decompressor { // protected Decompressor() { } - private enum Type {FILE, DIR, SYMLINK} + public enum Type {FILE, DIR, SYMLINK} - protected static class Entry { - final String name; - final Type type; - final boolean isWritable; - final boolean isExecutable; - final String linkTarget; + public static class Entry { + public final String name; + public final Type type; + public final boolean isWritable; + public final boolean isExecutable; + public final String linkTarget; protected Entry(String name, boolean isDirectory) { this(name, isDirectory ? Type.DIR : Type.FILE, true, false, null);