diff --git a/apps/i2psnark/java/src/org/klomp/snark/Snark.java b/apps/i2psnark/java/src/org/klomp/snark/Snark.java
index c2afec346..9d6cd9460 100644
--- a/apps/i2psnark/java/src/org/klomp/snark/Snark.java
+++ b/apps/i2psnark/java/src/org/klomp/snark/Snark.java
@@ -437,7 +437,7 @@ public class Snark
try { storage.close(); } catch (IOException ioee) {
ioee.printStackTrace();
}
- fatal("Could not create storage", ioe);
+ fatal("Could not check or create storage", ioe);
}
}
diff --git a/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java b/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java
index 59ab86a12..1ddaa6b03 100644
--- a/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java
+++ b/apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java
@@ -439,7 +439,10 @@ public class SnarkManager implements Snark.CompleteListener {
return null;
}
+ /** @throws RuntimeException via Snark.fatal() */
public void addTorrent(String filename) { addTorrent(filename, false); }
+
+ /** @throws RuntimeException via Snark.fatal() */
public void addTorrent(String filename, boolean dontAutoStart) {
if ((!dontAutoStart) && !_util.connected()) {
addMessage(_("Connecting to I2P"));
@@ -724,9 +727,13 @@ public class SnarkManager implements Snark.CompleteListener {
/** two listeners */
public void torrentComplete(Snark snark) {
- File f = new File(snark.torrent);
+ StringBuilder buf = new StringBuilder(256);
+ buf.append("").append(snark.storage.getBaseName()).append("");
long len = snark.meta.getTotalLength();
- addMessage(_("Download finished: \"{0}\"", f.getName()) + " (" + _("size: {0}B", DataHelper.formatSize2(len)) + ')');
+ addMessage(_("Download finished: {0}", buf.toString()) + " (" + _("size: {0}B", DataHelper.formatSize2(len)) + ')');
updateStatus(snark);
}
@@ -736,7 +743,7 @@ public class SnarkManager implements Snark.CompleteListener {
private void monitorTorrents(File dir) {
String fileNames[] = dir.list(TorrentFilenameFilter.instance());
- List foundNames = new ArrayList(0);
+ List foundNames = new ArrayList(0);
if (fileNames != null) {
for (int i = 0; i < fileNames.length; i++) {
try {
@@ -747,7 +754,7 @@ public class SnarkManager implements Snark.CompleteListener {
}
}
- Set existingNames = listTorrentFiles();
+ Set existingNames = listTorrentFiles();
// lets find new ones first...
for (int i = 0; i < foundNames.size(); i++) {
if (existingNames.contains(foundNames.get(i))) {
@@ -755,7 +762,13 @@ public class SnarkManager implements Snark.CompleteListener {
} else {
if (shouldAutoStart() && !_util.connect())
addMessage(_("Unable to connect to I2P!"));
- addTorrent((String)foundNames.get(i), !shouldAutoStart());
+ try {
+ // Snark.fatal() throws a RuntimeException
+ // don't let one bad torrent kill the whole loop
+ addTorrent(foundNames.get(i), !shouldAutoStart());
+ } catch (Exception e) {
+ addMessage(_("Unable to add {0}", foundNames.get(i)) + ": " + e);
+ }
}
}
// now lets see which ones have been removed...
@@ -765,7 +778,13 @@ public class SnarkManager implements Snark.CompleteListener {
// known and still there. noop
} else {
// known, but removed. drop it
- stopTorrent(name, true);
+ try {
+ // Snark.fatal() throws a RuntimeException
+ // don't let one bad torrent kill the whole loop
+ stopTorrent(name, true);
+ } catch (Exception e) {
+ // don't bother with message
+ }
}
}
}