From 456dc57129db36cf52ad4a505ba4ea52d50a3b84 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Mon, 5 May 2003 18:02:37 +0000 Subject: [PATCH] Moved the creation of the shutdown hook into the same static block that creates the temp cache directory so that it is only registered once even if multiple resource managers are created by the JVM (which happens in ant builds). git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2544 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../com/threerings/resource/ResourceBundle.java | 11 ++++++++++- .../com/threerings/resource/ResourceManager.java | 13 +------------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/java/com/threerings/resource/ResourceBundle.java b/src/java/com/threerings/resource/ResourceBundle.java index 1db265ab8..2803b2f94 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.12 2003/04/28 18:21:47 mdb Exp $ +// $Id: ResourceBundle.java,v 1.13 2003/05/05 18:02:37 mdb Exp $ package com.threerings.resource; @@ -15,6 +15,7 @@ import java.util.jar.JarEntry; import java.util.jar.JarFile; import com.samskivert.io.NestableIOException; +import com.samskivert.util.FileUtil; import com.samskivert.util.StringUtil; import org.apache.commons.io.StreamUtils; @@ -238,5 +239,13 @@ public class ResourceBundle Log.info("Creating narya temp cache directory '" + _tmpdir + "'."); _tmpdir.mkdirs(); } + + // add a hook to blow away the temp directory when we exit + Runtime.getRuntime().addShutdownHook(new Thread() { + public void run () { + Log.info("Clearing narya temp cache '" + _tmpdir + "'."); + FileUtil.recursiveDelete(_tmpdir); + } + }); } } diff --git a/src/java/com/threerings/resource/ResourceManager.java b/src/java/com/threerings/resource/ResourceManager.java index c43411290..f7f19845c 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.27 2003/05/03 00:51:13 ray Exp $ +// $Id: ResourceManager.java,v 1.28 2003/05/05 18:02:37 mdb Exp $ package com.threerings.resource; @@ -27,7 +27,6 @@ import javax.imageio.stream.FileImageInputStream; import javax.imageio.stream.ImageInputStream; import javax.imageio.stream.MemoryCacheImageInputStream; -import com.samskivert.util.FileUtil; import com.samskivert.util.StringUtil; import com.threerings.resource.DownloadManager.DownloadDescriptor; @@ -172,16 +171,6 @@ public class ResourceManager "won't be able to create our cache directory " + "either. [error=" + se + "]."); } - - // Add a hook to blow away the temp directory when we exit - Runtime.getRuntime().addShutdownHook(new Thread() { - public void run () - { - File dir = ResourceBundle.getCacheDir(); - Log.info("Deleting narya temp cache directory '" + dir + "'."); - FileUtil.recursiveDelete(dir); - } - }); } /**