aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-base/archiva-common
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2021-06-04 17:44:30 +0200
committerMartin Stockhammer <martin_s@apache.org>2021-06-04 17:44:30 +0200
commita1b92c562fae957e601875e50f87a3ff93fecfd6 (patch)
treed2efb37aafbf235b4b3d1d9d9d117ebaa315cc24 /archiva-modules/archiva-base/archiva-common
parent0ce53483a85b6b7a3a14417434edf56934b474ba (diff)
downloadarchiva-a1b92c562fae957e601875e50f87a3ff93fecfd6.tar.gz
archiva-a1b92c562fae957e601875e50f87a3ff93fecfd6.zip
Fixing Index context creation
Diffstat (limited to 'archiva-modules/archiva-base/archiva-common')
-rw-r--r--archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/common/utils/FileUtils.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/common/utils/FileUtils.java b/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/common/utils/FileUtils.java
index 3dc95432b..3ce13536a 100644
--- a/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/common/utils/FileUtils.java
+++ b/archiva-modules/archiva-base/archiva-common/src/main/java/org/apache/archiva/common/utils/FileUtils.java
@@ -23,9 +23,11 @@ import org.slf4j.LoggerFactory;
import java.io.*;
import java.nio.charset.Charset;
+import java.nio.file.CopyOption;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
import java.util.Comparator;
import java.util.Optional;
@@ -218,4 +220,22 @@ public class FileUtils {
});
}
}
+
+
+ public static void copyContent(Path srcDir, Path destinationDir, boolean overwrite) throws IOException
+ {
+ CopyOption[] copyOption = overwrite ? new CopyOption[]{StandardCopyOption.REPLACE_EXISTING} : new CopyOption[]{};
+ Files.walk(srcDir).forEach(a -> {
+ Path b = destinationDir.resolve(srcDir.relativize( a ));
+ try {
+ Files.copy(a, b, copyOption);
+ } catch (IOException e) {
+ log.error( "Could not copy file {} to {}: {}", a, b, e.getMessage( ) );
+ }
+ });
+ }
+
+ public static void copyContent(Path srcDir, Path destinationDir) throws IOException {
+ copyContent( srcDir, destinationDir, true );
+ }
}