add property pass-through support, directly check on Snark's completion

This commit is contained in:
Elizabeth Fong
2006-10-19 16:43:19 +00:00
parent 913d5d798e
commit cd02c01f30
2 changed files with 14 additions and 1 deletions
@@ -98,6 +98,15 @@ public class GetdownApplet extends JApplet
return;
}
// Pass through properties parameter.
String[] properties = getParameter("properties").split(" ");
for (String property : properties) {
String key = property.substring(property.indexOf("-D") + 2,
property.indexOf("="));
String value = property.substring(property.indexOf("=") + 1);
System.setProperty(key, value);
}
// when run from an applet, we install
String root;
if (RunAnywhere.isWindows()) {
@@ -85,7 +85,7 @@ public class TorrentDownloader extends Downloader
// Override the start time, since Snark allocates storage prior to
// doing any downloading
_start = System.currentTimeMillis();
while (_currentSize != snark.meta.getTotalLength()) {
while (!snark.coordinator.completed()) {
long now = System.currentTimeMillis();
if ((now - _lastUpdate) >= UPDATE_DELAY) {
_currentSize = snark.coordinator.getDownloaded();
@@ -106,6 +106,10 @@ public class TorrentDownloader extends Downloader
}
updateObserver();
}
// Manually set completion, just to be extra-safe.
_currentSize = _totalSize;
updateObserver();
if (snarkStopper != null) {
snarkStopper.run();
Runtime.getRuntime().removeShutdownHook(snarkStopper);