Cleanup (inlines single-use method)

This commit is contained in:
Roman Shevchenko
2018-07-27 18:40:51 +02:00
parent b1702d5ab7
commit a5eb6d0557
2 changed files with 4 additions and 8 deletions
@@ -120,13 +120,6 @@ public abstract class BaseUpdateAction extends PatchAction {
}
}
protected void writeDiff(File olderFile, File newerFile, OutputStream patchOutput) throws IOException {
try (BufferedInputStream olderFileIn = new BufferedInputStream(Utils.newFileInputStream(olderFile, myPatch.isNormalized()));
BufferedInputStream newerFileIn = new BufferedInputStream(new FileInputStream(newerFile))) {
writeDiff(olderFileIn, newerFileIn, patchOutput);
}
}
protected void writeDiff(InputStream olderFileIn, InputStream newerFileIn, OutputStream patchOutput) throws IOException {
Runner.logger().info("writing diff");
ByteArrayOutputStream diffOutput = new OpenByteArrayOutputStream();
@@ -27,7 +27,10 @@ public class UpdateAction extends BaseUpdateAction {
FileType type = getFileType(newerFile);
if (type == FileType.SYMLINK) throw new IOException("Unexpected symlink: " + newerFile);
writeFileType(patchOutput, type);
writeDiff(olderFile, newerFile, patchOutput);
try (BufferedInputStream olderFileIn = new BufferedInputStream(Utils.newFileInputStream(olderFile, myPatch.isNormalized()));
BufferedInputStream newerFileIn = new BufferedInputStream(new FileInputStream(newerFile))) {
writeDiff(olderFileIn, newerFileIn, patchOutput);
}
patchOutput.closeEntry();
}