i2psnark tmp files take 3
This commit is contained in:
@ -23,6 +23,7 @@ import net.i2p.data.DataFormatException;
|
|||||||
import net.i2p.data.Destination;
|
import net.i2p.data.Destination;
|
||||||
import net.i2p.data.Hash;
|
import net.i2p.data.Hash;
|
||||||
import net.i2p.util.EepGet;
|
import net.i2p.util.EepGet;
|
||||||
|
import net.i2p.util.FileUtil;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
import net.i2p.util.SimpleScheduler;
|
import net.i2p.util.SimpleScheduler;
|
||||||
import net.i2p.util.SimpleTimer;
|
import net.i2p.util.SimpleTimer;
|
||||||
@ -49,6 +50,7 @@ public class I2PSnarkUtil {
|
|||||||
private int _maxUploaders;
|
private int _maxUploaders;
|
||||||
private int _maxUpBW;
|
private int _maxUpBW;
|
||||||
private int _maxConnections;
|
private int _maxConnections;
|
||||||
|
private File _tmpDir;
|
||||||
|
|
||||||
public static final String PROP_USE_OPENTRACKERS = "i2psnark.useOpentrackers";
|
public static final String PROP_USE_OPENTRACKERS = "i2psnark.useOpentrackers";
|
||||||
public static final boolean DEFAULT_USE_OPENTRACKERS = true;
|
public static final boolean DEFAULT_USE_OPENTRACKERS = true;
|
||||||
@ -68,6 +70,12 @@ public class I2PSnarkUtil {
|
|||||||
_maxUploaders = Snark.MAX_TOTAL_UPLOADERS;
|
_maxUploaders = Snark.MAX_TOTAL_UPLOADERS;
|
||||||
_maxUpBW = DEFAULT_MAX_UP_BW;
|
_maxUpBW = DEFAULT_MAX_UP_BW;
|
||||||
_maxConnections = MAX_CONNECTIONS;
|
_maxConnections = MAX_CONNECTIONS;
|
||||||
|
// This is used for both announce replies and .torrent file downloads,
|
||||||
|
// so it must be available even if not connected to I2CP.
|
||||||
|
// so much for multiple instances
|
||||||
|
_tmpDir = new File("tmp", "i2psnark");
|
||||||
|
FileUtil.rmdir(_tmpDir, false);
|
||||||
|
_tmpDir.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,6 +103,7 @@ public class I2PSnarkUtil {
|
|||||||
_i2cpHost = i2cpHost;
|
_i2cpHost = i2cpHost;
|
||||||
if (i2cpPort > 0)
|
if (i2cpPort > 0)
|
||||||
_i2cpPort = i2cpPort;
|
_i2cpPort = i2cpPort;
|
||||||
|
// can't remove any options this way...
|
||||||
if (opts != null)
|
if (opts != null)
|
||||||
_opts.putAll(opts);
|
_opts.putAll(opts);
|
||||||
_configured = true;
|
_configured = true;
|
||||||
@ -167,6 +176,10 @@ public class I2PSnarkUtil {
|
|||||||
_manager = null;
|
_manager = null;
|
||||||
_shitlist.clear();
|
_shitlist.clear();
|
||||||
mgr.destroySocketManager();
|
mgr.destroySocketManager();
|
||||||
|
// this will delete a .torrent file d/l in progress so don't do that...
|
||||||
|
FileUtil.rmdir(_tmpDir, false);
|
||||||
|
// in case the user will d/l a .torrent file next...
|
||||||
|
_tmpDir.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** connect to the given destination */
|
/** connect to the given destination */
|
||||||
@ -205,7 +218,8 @@ public class I2PSnarkUtil {
|
|||||||
_log.debug("Fetching [" + url + "] proxy=" + _proxyHost + ":" + _proxyPort + ": " + _shouldProxy);
|
_log.debug("Fetching [" + url + "] proxy=" + _proxyHost + ":" + _proxyPort + ": " + _shouldProxy);
|
||||||
File out = null;
|
File out = null;
|
||||||
try {
|
try {
|
||||||
out = File.createTempFile("i2psnark", "url", new File("."));
|
// we could use the system tmp dir but deleteOnExit() doesn't seem to work on all platforms...
|
||||||
|
out = File.createTempFile("i2psnark", null, _tmpDir);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
ioe.printStackTrace();
|
ioe.printStackTrace();
|
||||||
if (out != null)
|
if (out != null)
|
||||||
|
Reference in New Issue
Block a user