forked from I2P_Developers/i2p.i2p
i2psnark: Fix autostart for torrent files copied into the dir
Use Collator for case-insensitive sort Use Exception.getLocalizedMessage() Prevent duplicate torrent starts Don't write debug info to wrapper log Increase max piece size Navbar cleanup
This commit is contained in:
@ -552,6 +552,8 @@ public class Snark
|
||||
* @throws RuntimeException via fatal()
|
||||
*/
|
||||
public synchronized void startTorrent() {
|
||||
if (!stopped)
|
||||
return;
|
||||
starting = true;
|
||||
try {
|
||||
x_startTorrent();
|
||||
|
@ -1590,7 +1590,7 @@ public class SnarkManager implements CompleteListener, ClientApp {
|
||||
fis = new FileInputStream(sfile);
|
||||
} catch (IOException ioe) {
|
||||
// catch this here so we don't try do delete it below
|
||||
addMessage(_t("Cannot open \"{0}\"", sfile.getName()) + ": " + ioe.getMessage());
|
||||
addMessage(_t("Cannot open \"{0}\"", sfile.getName()) + ": " + ioe.getLocalizedMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1654,13 +1654,13 @@ public class SnarkManager implements CompleteListener, ClientApp {
|
||||
} catch (IOException ioe) {
|
||||
// close before rename/delete for windows
|
||||
if (fis != null) try { fis.close(); fis = null; } catch (IOException ioe2) {}
|
||||
String err = _t("Torrent in \"{0}\" is invalid", sfile.toString()) + ": " + ioe.getMessage();
|
||||
String err = _t("Torrent in \"{0}\" is invalid", sfile.toString()) + ": " + ioe.getLocalizedMessage();
|
||||
addMessage(err);
|
||||
_log.error(err, ioe);
|
||||
disableTorrentFile(filename);
|
||||
return false;
|
||||
} catch (OutOfMemoryError oom) {
|
||||
addMessage(_t("ERROR - Out of memory, cannot create torrent from {0}", sfile.getName()) + ": " + oom.getMessage());
|
||||
addMessage(_t("ERROR - Out of memory, cannot create torrent from {0}", sfile.getName()) + ": " + oom.getLocalizedMessage());
|
||||
return false;
|
||||
} finally {
|
||||
if (fis != null) try { fis.close(); } catch (IOException ioe) {}
|
||||
@ -2232,13 +2232,17 @@ public class SnarkManager implements CompleteListener, ClientApp {
|
||||
*/
|
||||
private void locked_saveTorrentStatus(byte[] ih, Properties config) {
|
||||
File conf = configFile(_configDir, ih);
|
||||
if (shouldAutoStart() && !conf.exists()) {
|
||||
// force on for new torrents
|
||||
config.setProperty(PROP_META_RUNNING, "true");
|
||||
}
|
||||
File subdir = conf.getParentFile();
|
||||
if (!subdir.exists())
|
||||
subdir.mkdirs();
|
||||
try {
|
||||
DataHelper.storeProps(config, conf);
|
||||
if (_log.shouldInfo())
|
||||
_log.info("Saved config to " + conf);
|
||||
_log.info("Saved config to " + conf /* , new Exception() */ );
|
||||
} catch (IOException ioe) {
|
||||
_log.error("Unable to save the config to " + conf);
|
||||
}
|
||||
@ -2391,12 +2395,13 @@ public class SnarkManager implements CompleteListener, ClientApp {
|
||||
} else if (info.getTotalLength() <= 0) {
|
||||
return _t("Torrent \"{0}\" has no data!", info.getName());
|
||||
} else if (info.getTotalLength() > Storage.MAX_TOTAL_SIZE) {
|
||||
/*
|
||||
System.out.println("torrent info: " + info.toString());
|
||||
List<Long> lengths = info.getLengths();
|
||||
if (lengths != null)
|
||||
for (int i = 0; i < lengths.size(); i++)
|
||||
System.out.println("File " + i + " is " + lengths.get(i) + " long.");
|
||||
|
||||
*/
|
||||
return _t("Torrents larger than {0}B are not supported yet \"{1}\"!", Storage.MAX_TOTAL_SIZE, info.getName());
|
||||
} else {
|
||||
// ok
|
||||
@ -2414,7 +2419,7 @@ public class SnarkManager implements CompleteListener, ClientApp {
|
||||
filename = sfile.getCanonicalPath();
|
||||
} catch (IOException ioe) {
|
||||
_log.error("Unable to remove the torrent " + filename, ioe);
|
||||
addMessage(_t("Error: Could not remove the torrent {0}", filename) + ": " + ioe.getMessage());
|
||||
addMessage(_t("Error: Could not remove the torrent {0}", filename) + ": " + ioe.getLocalizedMessage());
|
||||
return null;
|
||||
}
|
||||
int remaining = 0;
|
||||
@ -2709,8 +2714,8 @@ public class SnarkManager implements CompleteListener, ClientApp {
|
||||
}
|
||||
|
||||
Set<String> existingNames = listTorrentFiles();
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("DirMon found: " + DataHelper.toString(foundNames) + " existing: " + DataHelper.toString(existingNames));
|
||||
//if (_log.shouldLog(Log.DEBUG))
|
||||
// _log.debug("DirMon found: " + DataHelper.toString(foundNames) + " existing: " + DataHelper.toString(existingNames));
|
||||
// lets find new ones first...
|
||||
boolean shouldStart = shouldAutoStart();
|
||||
for (String name : foundNames) {
|
||||
@ -3092,8 +3097,9 @@ public class SnarkManager implements CompleteListener, ClientApp {
|
||||
* @since 0.9
|
||||
*/
|
||||
private static class IgnoreCaseComparator implements Comparator<Tracker>, Serializable {
|
||||
private final Collator coll = Collator.getInstance();
|
||||
public int compare(Tracker l, Tracker r) {
|
||||
return l.name.toLowerCase().compareTo(r.name.toLowerCase());
|
||||
return coll.compare(l.name, r.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public class Storage implements Closeable
|
||||
/** The default piece size. */
|
||||
private static final int DEFAULT_PIECE_SIZE = 256*1024;
|
||||
/** bigger than this will be rejected */
|
||||
public static final int MAX_PIECE_SIZE = 16*1024*1024;
|
||||
public static final int MAX_PIECE_SIZE = 32*1024*1024;
|
||||
/** The maximum number of pieces in a torrent. */
|
||||
public static final int MAX_PIECES = 32*1024;
|
||||
public static final long MAX_TOTAL_SIZE = MAX_PIECE_SIZE * (long) MAX_PIECES;
|
||||
|
@ -728,7 +728,6 @@ td.subHeaderPriority, td.priority {
|
||||
td.subHeaderPriority {
|
||||
background: #020;
|
||||
font-weight: bold;
|
||||
background: url(images/snarktopnav.png) repeat-x scroll center center #110011;
|
||||
background-image: linear-gradient(to bottom, #030 0%, #020 50%, #000 51%);
|
||||
text-align: center !important;
|
||||
padding: 0 1px !important;
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 163 B |
@ -80,12 +80,6 @@ body {
|
||||
.snarknavbar {
|
||||
margin: -10px 0 10px 0 !important;
|
||||
padding: 15px 10px 14px;
|
||||
border: 1px solid #101;
|
||||
border-radius: 0 0 4px 4px;
|
||||
box-shadow: inset 0 0 0 1px #3f173f, inset 0 0 3px 1px #212;
|
||||
filter: drop-shadow(0 1px 4px #101);
|
||||
background: #101 url(images/snarktopnav.png) repeat-x scroll center center;
|
||||
background: linear-gradient(to bottom, #522852, #4a2449 11%, #321831 33%, #281428 51%, #1c0e1c 52%, #101 54%);
|
||||
min-width: 600px;
|
||||
width: 70%;
|
||||
text-align: center;
|
||||
|
Reference in New Issue
Block a user