You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2021/06/16 03:44:28 UTC
[karaf] branch main updated: [KARAF-7146] clean argument doesn't
remove the log
This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/karaf.git
The following commit(s) were added to refs/heads/main by this push:
new df23b2d [KARAF-7146] clean argument doesn't remove the log
new 54595c2 Merge pull request #1391 from jbonofre/KARAF-7146
df23b2d is described below
commit df23b2d25ac4672a648c0e6cfdeb96f1ad1579b9
Author: jbonofre <jb...@apache.org>
AuthorDate: Sun Jun 13 09:47:34 2021 +0200
[KARAF-7146] clean argument doesn't remove the log
---
main/src/main/java/org/apache/karaf/main/Main.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/main/src/main/java/org/apache/karaf/main/Main.java b/main/src/main/java/org/apache/karaf/main/Main.java
index 25b6166..a5f6bf3 100644
--- a/main/src/main/java/org/apache/karaf/main/Main.java
+++ b/main/src/main/java/org/apache/karaf/main/Main.java
@@ -238,17 +238,22 @@ public class Main {
if (Arrays.asList(args).contains("clean")) {
// clean instance
final Path dataDir = new File(System.getProperty(ConfigProperties.PROP_KARAF_DATA)).toPath();
+ final Path logDir = new File(System.getProperty(ConfigProperties.PROP_KARAF_LOG)).toPath();
if (Files.exists(dataDir)) {
try {
Files.walkFileTree(dataDir, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(final Path file, final BasicFileAttributes attributes) throws IOException {
- Files.delete(file);
+ if (!file.startsWith(logDir)) {
+ Files.delete(file);
+ }
return super.visitFile(file, attributes);
}
@Override
public FileVisitResult postVisitDirectory(final Path dir, final IOException exception) throws IOException {
- Files.delete(dir);
+ if (dir.compareTo(logDir) != 0) {
+ Files.delete(dir);
+ }
return super.postVisitDirectory(dir, exception);
}
});