Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/main/java/codechicken/diffpatch/cli/PatchOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.*;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Stream;

import static codechicken.diffpatch.util.LogLevel.*;
import static codechicken.diffpatch.util.Utils.filterPrefixed;
Expand Down Expand Up @@ -331,6 +332,23 @@ public boolean doPatch(FileCollector oCollector, FileCollector rCollector, Patch

for (String file : removedFiles) {
summary.removedFiles++;
Path deletedFile = this.outputPath.toPath().resolve(file);
Files.delete(deletedFile);
try(Stream<Path> walker = Files.walk(this.outputPath.toPath())){
walker.sorted(Comparator.reverseOrder())
.filter(Files::isDirectory)
.filter(path -> {
try(Stream<Path> folders = Files.list(path)) {
return !folders.findFirst().isPresent();
} catch (IOException e) {
return false;
}
})
.map(Path::toFile)
.forEach(File::delete);
}


log(DEBUG, "Removed: " + file);
}

Expand Down