|
@@ -20,10 +20,12 @@
|
|
|
package org.elasticsearch.packaging.util;
|
|
|
|
|
|
import java.nio.file.Files;
|
|
|
+import java.nio.file.Path;
|
|
|
import java.nio.file.Paths;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
+import java.util.function.Consumer;
|
|
|
|
|
|
import static org.elasticsearch.packaging.util.FileUtils.getTempDir;
|
|
|
import static org.elasticsearch.packaging.util.FileUtils.lsGlob;
|
|
@@ -79,13 +81,13 @@ public class Cleanup {
|
|
|
|
|
|
// delete files that may still exist
|
|
|
lsGlob(getTempDir(), "elasticsearch*").forEach(FileUtils::rm);
|
|
|
- final List<String> filesToDelete = Platforms.WINDOWS
|
|
|
- ? ELASTICSEARCH_FILES_WINDOWS
|
|
|
- : ELASTICSEARCH_FILES_LINUX;
|
|
|
+ final List<String> filesToDelete = Platforms.WINDOWS ? ELASTICSEARCH_FILES_WINDOWS : ELASTICSEARCH_FILES_LINUX;
|
|
|
+ // windows needs leniency due to asinine releasing of file locking async from a process exiting
|
|
|
+ Consumer<? super Path> rm = Platforms.WINDOWS ? FileUtils::rmWithRetries : FileUtils::rm;
|
|
|
filesToDelete.stream()
|
|
|
.map(Paths::get)
|
|
|
.filter(Files::exists)
|
|
|
- .forEach(FileUtils::rm);
|
|
|
+ .forEach(rm);
|
|
|
|
|
|
// disable elasticsearch service
|
|
|
// todo add this for windows when adding tests for service intallation
|