From 1b39feaab7a19fed659542a41d6ce95b089dd347 Mon Sep 17 00:00:00 2001 From: gnembon Date: Sun, 23 May 2021 14:00:49 -0300 Subject: [PATCH] wrap stream before closing zip files. --- src/main/java/carpet/script/argument/FileArgument.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/carpet/script/argument/FileArgument.java b/src/main/java/carpet/script/argument/FileArgument.java index d4fb6152..bd490ec8 100644 --- a/src/main/java/carpet/script/argument/FileArgument.java +++ b/src/main/java/carpet/script/argument/FileArgument.java @@ -244,11 +244,10 @@ public class FileArgument Path rootPath = moduleRootPath(module); if (rootPath == null) return null; String zipComponent = (zipContainer != null) ? rootPath.relativize(zipPath).toString() : null; - strings = result.map(p -> { - if (zipContainer == null) - return rootPath.relativize(p).toString().replaceAll("[\\\\/]+", "/"); - return (zipComponent + '/'+ p.toString()).replaceAll("[\\\\/]+", "/"); - }); + strings = (zipContainer == null) + ? result.map(p -> rootPath.relativize(p).toString().replaceAll("[\\\\/]+", "/")) + // need to remove ties to the zip file system before closing, so wrapping the stream + : result.map(p -> (zipComponent + '/'+ p.toString()).replaceAll("[\\\\/]+", "/")).collect(Collectors.toList()).stream(); } } finally {