diff --git a/src/java/com/threerings/resource/JNLPDownloader.java b/src/java/com/threerings/resource/JNLPDownloader.java index f39852cca..d12877896 100644 --- a/src/java/com/threerings/resource/JNLPDownloader.java +++ b/src/java/com/threerings/resource/JNLPDownloader.java @@ -1,5 +1,5 @@ // -// $Id: JNLPDownloader.java,v 1.10 2003/10/29 22:31:55 mdb Exp $ +// $Id: JNLPDownloader.java,v 1.11 2003/10/29 23:09:48 mdb Exp $ package com.threerings.resource; @@ -195,6 +195,16 @@ public class JNLPDownloader extends Downloader if (!_patchFile.delete()) { Log.warning("Failed to delete patch file " + _curFile + "."); } + + // delete any old unversioned version of the .jar file + File unverDest = new File(ResourceManager.unversionPath( + _desc.destFile.getPath(), ".jar")); + if (unverDest.exists()) { + if (!unverDest.delete()) { + Log.warning("Failed to delete old unversioned bundle '" + + unverDest + "'."); + } + } } PrintWriter pout = new PrintWriter( diff --git a/src/java/com/threerings/resource/ResourceBundle.java b/src/java/com/threerings/resource/ResourceBundle.java index 17becc6e7..a38c4e57c 100644 --- a/src/java/com/threerings/resource/ResourceBundle.java +++ b/src/java/com/threerings/resource/ResourceBundle.java @@ -1,5 +1,5 @@ // -// $Id: ResourceBundle.java,v 1.24 2003/10/22 18:50:27 mdb Exp $ +// $Id: ResourceBundle.java,v 1.25 2003/10/29 23:09:48 mdb Exp $ package com.threerings.resource; @@ -50,7 +50,9 @@ public class ResourceBundle { _source = source; if (unpack) { - String root = stripSuffix(source.getPath()); + String root = ResourceManager.unversionPath( + source.getPath(), ".jar"); + root = stripSuffix(root); _unpacked = new File(root + ".stamp"); _cache = new File(root); } diff --git a/src/java/com/threerings/resource/ResourceManager.java b/src/java/com/threerings/resource/ResourceManager.java index 3e6b36416..f069eb5f5 100644 --- a/src/java/com/threerings/resource/ResourceManager.java +++ b/src/java/com/threerings/resource/ResourceManager.java @@ -1,5 +1,5 @@ // -// $Id: ResourceManager.java,v 1.38 2003/10/29 22:31:55 mdb Exp $ +// $Id: ResourceManager.java,v 1.39 2003/10/29 23:09:48 mdb Exp $ package com.threerings.resource; @@ -870,7 +870,7 @@ public class ResourceManager if (!suffix.startsWith(".")) { suffix = "." + suffix; } - int sidx = path.indexOf(suffix); + int sidx = path.lastIndexOf(suffix); if (sidx == -1) { Log.warning("Invalid unversioned path, missing suffix " + "[path=" + path + ", suffix=" + suffix + "]."); @@ -879,6 +879,28 @@ public class ResourceManager return path.substring(0, sidx) + "__V" + version + suffix; } + /** + * Creates an unversioned version of the supplied path. If the path is + * not versioned, the existing path will be returned. + */ + public static String unversionPath (String path, String suffix) + { + if (!suffix.startsWith(".")) { + suffix = "." + suffix; + } + int vidx = path.indexOf("__V"); + if (vidx == -1) { + return path; + } + int sidx = path.lastIndexOf(suffix); + if (sidx == -1) { + Log.warning("Invalid versioned path, missing suffix " + + "[path=" + path + ", suffix=" + suffix + "]."); + return path; + } + return path.substring(0, vidx) + suffix; + } + /** * Returns the suffix of the specified path, ie. .jar if * the path references a file that ends in .jar.