aboutsummaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@yahooinc.com>2021-09-06 19:36:09 +0200
committerHarald Musum <musum@yahooinc.com>2021-09-06 19:36:09 +0200
commit9bd7b42ce9701c6cf737a30bfe43d692322d7005 (patch)
treeba3966c1747d2997b518ba68e1dfb91f9a3f342e /configserver
parent39bf4a6d515e43b79aa8b145a2da55eb9101ee69 (diff)
Cleanup temp directories properly
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/ApplicationFileManager.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/ApplicationFileManager.java b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/ApplicationFileManager.java
index 52d443e6998..24bfc178ee8 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/ApplicationFileManager.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/ApplicationFileManager.java
@@ -15,6 +15,7 @@ import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.nio.file.Paths;
/**
* @author baldersheim
@@ -47,7 +48,7 @@ public class ApplicationFileManager implements AddFileInterface {
} catch (IOException e) {
throw new IllegalArgumentException(e);
} finally {
- IOUtils.recursiveDeleteDir(file);
+ cleanup(file, relativePath);
}
}
@@ -59,7 +60,7 @@ public class ApplicationFileManager implements AddFileInterface {
} catch (IOException e) {
throw new IllegalArgumentException(e);
} finally {
- IOUtils.recursiveDeleteDir(file.getParentFile());
+ cleanup(file, relativePath);
}
}
@@ -123,4 +124,13 @@ public class ApplicationFileManager implements AddFileInterface {
}
}
+ private void cleanup(File file, String relativePath) {
+ Path pathToDelete = file.toPath();
+ // Remove as many components as there are in relative path to find temp path to delete
+ for (int i = 0; i < Paths.get(relativePath).getNameCount(); i++)
+ pathToDelete = pathToDelete.resolveSibling("");
+ IOUtils.recursiveDeleteDir(pathToDelete.toFile());
+ }
+
+
}