Further juicy goodness.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: Application.java,v 1.4 2004/07/06 05:13:35 mdb Exp $
|
||||
// $Id: Application.java,v 1.5 2004/07/06 09:46:35 mdb Exp $
|
||||
|
||||
package com.threerings.getdown.data;
|
||||
|
||||
@@ -256,7 +256,7 @@ public class Application
|
||||
args[idx++] = processArg((String)iter.next());
|
||||
}
|
||||
|
||||
Log.info("Running " + StringUtil.join(args, "\n"));
|
||||
Log.info("Running " + StringUtil.join(args, "\n "));
|
||||
return Runtime.getRuntime().exec(args, null);
|
||||
}
|
||||
|
||||
@@ -306,11 +306,25 @@ public class Application
|
||||
"Attempting recovery...");
|
||||
}
|
||||
|
||||
// if we failed to load the digest, try to redownload the digest
|
||||
// file and give it another good college try; this time we allow
|
||||
// exceptions to propagate up to the caller as there is nothing
|
||||
// else we can do to recover
|
||||
if (_digest == null) {
|
||||
// if we have no version, then we are running in unversioned mode
|
||||
// so we need to download our digest.txt file on every invocation
|
||||
if (_version == -1) {
|
||||
// make a note of the old meta-digest, if this changes we need
|
||||
// to revalidate all of our resources as one or more of them
|
||||
// have also changed
|
||||
String olddig = (_digest == null) ? "" : _digest.getMetaDigest();
|
||||
downloadControlFile(Digest.DIGEST_FILE);
|
||||
_digest = new Digest(_appdir);
|
||||
if (!olddig.equals(_digest.getMetaDigest())) {
|
||||
Log.info("Unversioned digest changed. Revalidating...");
|
||||
clearValidationMarkers();
|
||||
}
|
||||
|
||||
} else if (_digest == null) {
|
||||
// if we failed to load the digest, try to redownload the
|
||||
// digest file and give it another good college try; this time
|
||||
// we allow exceptions to propagate up to the caller as there
|
||||
// is nothing else we can do to recover
|
||||
downloadControlFile(Digest.DIGEST_FILE);
|
||||
_digest = new Digest(_appdir);
|
||||
}
|
||||
@@ -391,6 +405,22 @@ public class Application
|
||||
}
|
||||
}
|
||||
|
||||
/** Clears all validation marker files. */
|
||||
protected void clearValidationMarkers ()
|
||||
{
|
||||
clearValidationMarkers(_codes.iterator());
|
||||
clearValidationMarkers(_resources.iterator());
|
||||
}
|
||||
|
||||
/** Clears all validation marker files for the resources in the
|
||||
* supplied iterator. */
|
||||
protected void clearValidationMarkers (Iterator iter)
|
||||
{
|
||||
while (iter.hasNext()) {
|
||||
((Resource)iter.next()).clearMarker();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads a new copy of the specified control file and, if the
|
||||
* download is successful, moves it over the old file on the
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: Digest.java,v 1.2 2004/07/02 15:22:49 mdb Exp $
|
||||
// $Id: Digest.java,v 1.3 2004/07/06 09:46:35 mdb Exp $
|
||||
|
||||
package com.threerings.getdown.data;
|
||||
|
||||
@@ -39,13 +39,12 @@ public class Digest
|
||||
throws IOException
|
||||
{
|
||||
// parse and validate our digest file contents
|
||||
String metaDigest = "";
|
||||
StringBuffer data = new StringBuffer();
|
||||
List pairs = ConfigUtil.parsePairs(new File(appdir, DIGEST_FILE));
|
||||
for (Iterator iter = pairs.iterator(); iter.hasNext(); ) {
|
||||
String[] pair = (String[])iter.next();
|
||||
if (pair[0].equals(DIGEST_FILE)) {
|
||||
metaDigest = pair[1];
|
||||
_metaDigest = pair[1];
|
||||
break;
|
||||
}
|
||||
_digests.put(pair[0], pair[1]);
|
||||
@@ -56,21 +55,20 @@ public class Digest
|
||||
MessageDigest md = getMessageDigest();
|
||||
byte[] contents = data.toString().getBytes("UTF-8");
|
||||
String md5 = StringUtil.hexlate(md.digest(contents));
|
||||
if (!md5.equals(metaDigest)) {
|
||||
if (!md5.equals(_metaDigest)) {
|
||||
String err = MessageUtil.tcompose(
|
||||
"m.invalid_digest_file", metaDigest, md5);
|
||||
"m.invalid_digest_file", _metaDigest, md5);
|
||||
throw new IOException(err);
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Returns the stored digest value for the file with the supplied
|
||||
// * path, or null if no digest exists for a file with that path.
|
||||
// */
|
||||
// public String getDigest (String path)
|
||||
// {
|
||||
// return (String)_digests.get(path);
|
||||
// }
|
||||
/**
|
||||
* Returns the digest for the digest file.
|
||||
*/
|
||||
public String getMetaDigest ()
|
||||
{
|
||||
return _metaDigest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the MD5 hash of the specified resource and compares it
|
||||
@@ -145,4 +143,5 @@ public class Digest
|
||||
}
|
||||
|
||||
protected HashMap _digests = new HashMap();
|
||||
protected String _metaDigest = "";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: Resource.java,v 1.4 2004/07/06 05:13:36 mdb Exp $
|
||||
// $Id: Resource.java,v 1.5 2004/07/06 09:46:35 mdb Exp $
|
||||
|
||||
package com.threerings.getdown.data;
|
||||
|
||||
@@ -78,6 +78,10 @@ public class Resource
|
||||
*/
|
||||
public boolean isMarkedValid ()
|
||||
{
|
||||
if (!_local.exists()) {
|
||||
clearMarker();
|
||||
return false;
|
||||
}
|
||||
return _marker.exists();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user