From dcea064ecbf7990a5beba32fa1237a2465cbf43f Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Mon, 18 Oct 2004 21:39:18 +0000 Subject: [PATCH] Allow the BundledComponentRepository to be configured to wipe out its bundle cache if it fails to locate the data for a character action. Also updated wipeBundle() signature. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3147 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../threerings/cast/bundle/BundleUtil.java | 4 ++-- .../bundle/BundledComponentRepository.java | 20 ++++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/java/com/threerings/cast/bundle/BundleUtil.java b/src/java/com/threerings/cast/bundle/BundleUtil.java index 66764576d..a8dc91abd 100644 --- a/src/java/com/threerings/cast/bundle/BundleUtil.java +++ b/src/java/com/threerings/cast/bundle/BundleUtil.java @@ -1,5 +1,5 @@ // -// $Id: BundleUtil.java,v 1.9 2004/08/27 02:12:27 mdb Exp $ +// $Id: BundleUtil.java,v 1.10 2004/10/18 21:39:18 mdb Exp $ // // Narya library - tools for developing networked games // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved @@ -99,7 +99,7 @@ public class BundleUtil if (wipeBundleOnFailure) { StreamUtil.close(bin); bin = null; - bundle.wipeBundle(); + bundle.wipeBundle(false); } throw ioe; diff --git a/src/java/com/threerings/cast/bundle/BundledComponentRepository.java b/src/java/com/threerings/cast/bundle/BundledComponentRepository.java index 5d89c1a5f..50a51ccf6 100644 --- a/src/java/com/threerings/cast/bundle/BundledComponentRepository.java +++ b/src/java/com/threerings/cast/bundle/BundledComponentRepository.java @@ -1,5 +1,5 @@ // -// $Id: BundledComponentRepository.java,v 1.34 2004/08/27 02:12:27 mdb Exp $ +// $Id: BundledComponentRepository.java,v 1.35 2004/10/18 21:39:18 mdb Exp $ // // Narya library - tools for developing networked games // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved @@ -156,6 +156,18 @@ public class BundledComponentRepository } } + /** + * Configures the bundled component repository to wipe any bundles + * that report certain kinds of failure. In the event that an unpacked + * bundle becomes corrupt, this is useful in that it will force the + * bundle to be unpacked on the next application invocation, + * potentially remedying the problem of a corrupt unpacking. + */ + public void setWipeOnFailure (boolean wipeOnFailure) + { + _wipeOnFailure = true; + } + // documentation inherited public CharacterComponent getComponent (int componentId) throws NoSuchComponentException @@ -332,6 +344,9 @@ public class BundledComponentRepository if (aset == null) { Log.warning("Unable to locate tileset for action '" + action + "' " + component + "."); + if (_wipeOnFailure) { + _bundle.wipeBundle(false); + } return null; } @@ -504,4 +519,7 @@ public class BundledComponentRepository /** The component table. */ protected HashIntMap _components = new HashIntMap(); + + /** Whether or not we wipe our bundles on any failure. */ + protected boolean _wipeOnFailure; }