diff options
Diffstat (limited to 'configserver')
-rw-r--r-- | configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/ApplicationFileManager.java | 14 |
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()); + } + + } |