From bb4b9e3390ca65bd406b4730a44ec54246994dc6 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 5 Jan 2022 07:25:56 -0800 Subject: [PATCH] JarDiffPatcher needs to support .old files. When patching, Getdown will move foo.jar to foo.jar.old and then patch that file to create a new foo.jar. That results in foo.jar.old being passed into JarDiffPatcher as the source file, which it then inspects to determine whether it is a zip file or a jar file based on its file extension. Since that file extension has already changed to .xxx.old, we need to handle that. Closes #230. --- .../java/com/threerings/getdown/tools/JarDiffPatcher.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/threerings/getdown/tools/JarDiffPatcher.java b/core/src/main/java/com/threerings/getdown/tools/JarDiffPatcher.java index e55034b..a65cbeb 100644 --- a/core/src/main/java/com/threerings/getdown/tools/JarDiffPatcher.java +++ b/core/src/main/java/com/threerings/getdown/tools/JarDiffPatcher.java @@ -282,8 +282,11 @@ public class JarDiffPatcher implements JarDiffCodes throws IOException { FileOutputStream out = new FileOutputStream(target); - if (source.getName().endsWith(".jar")) return new JarOutputStream(out); - else if (source.getName().endsWith(".zip")) return new ZipOutputStream(out); + String sourceName = source.getName(); + if (sourceName.endsWith(".jar") || + sourceName.endsWith(".jar.old")) return new JarOutputStream(out); + else if (sourceName.endsWith(".zip") || + sourceName.endsWith(".zip.old")) return new ZipOutputStream(out); else throw new AssertionError("Unsupported source file '" + source + "'. Not a .jar or .zip?"); }