forked from I2P_Developers/i2p.i2p
i2psnark: Don't fail to start if data directory not found (ticket #2166)
Try to create dir if doesn't exist Hide add and create sections if dir not writable Remove 403 handler, don't want it for standalone hostname check
This commit is contained in:
@ -1058,13 +1058,27 @@ public class SnarkManager implements CompleteListener, ClientApp {
|
|||||||
} catch (NumberFormatException nfe) {}
|
} catch (NumberFormatException nfe) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set this before we check the data dir
|
||||||
|
if (areFilesPublic() != filesPublic) {
|
||||||
|
_config.setProperty(PROP_FILES_PUBLIC, Boolean.toString(filesPublic));
|
||||||
|
_util.setFilesPublic(filesPublic);
|
||||||
|
if (filesPublic)
|
||||||
|
addMessage(_t("New files will be publicly readable"));
|
||||||
|
else
|
||||||
|
addMessage(_t("New files will not be publicly readable"));
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (dataDir != null && !dataDir.equals(getDataDir().getAbsolutePath())) {
|
if (dataDir != null && !dataDir.equals(getDataDir().getAbsolutePath())) {
|
||||||
dataDir = DataHelper.stripHTML(dataDir.trim());
|
dataDir = DataHelper.stripHTML(dataDir.trim());
|
||||||
File dd = new File(dataDir);
|
File dd = areFilesPublic() ? new File(dataDir) : new SecureDirectory(dataDir);
|
||||||
if (!dd.isAbsolute()) {
|
if (!dd.isAbsolute()) {
|
||||||
addMessage(_t("Data directory must be an absolute path") + ": " + dataDir);
|
addMessage(_t("Data directory must be an absolute path") + ": " + dataDir);
|
||||||
} else if (!dd.exists()) {
|
} else if (!dd.exists() && !dd.mkdirs()) {
|
||||||
addMessage(_t("Data directory does not exist") + ": " + dataDir);
|
// save this tag for now, may need it again
|
||||||
|
if (false)
|
||||||
|
addMessage(_t("Data directory does not exist") + ": " + dataDir);
|
||||||
|
addMessage(_t("Data directory cannot be created") + ": " + dataDir);
|
||||||
} else if (!dd.isDirectory()) {
|
} else if (!dd.isDirectory()) {
|
||||||
addMessage(_t("Not a directory") + ": " + dataDir);
|
addMessage(_t("Not a directory") + ": " + dataDir);
|
||||||
} else if (!dd.canRead()) {
|
} else if (!dd.canRead()) {
|
||||||
@ -1196,16 +1210,6 @@ public class SnarkManager implements CompleteListener, ClientApp {
|
|||||||
changed = true;
|
changed = true;
|
||||||
} // reconnect || changed options
|
} // reconnect || changed options
|
||||||
|
|
||||||
if (areFilesPublic() != filesPublic) {
|
|
||||||
_config.setProperty(PROP_FILES_PUBLIC, Boolean.toString(filesPublic));
|
|
||||||
_util.setFilesPublic(filesPublic);
|
|
||||||
if (filesPublic)
|
|
||||||
addMessage(_t("New files will be publicly readable"));
|
|
||||||
else
|
|
||||||
addMessage(_t("New files will not be publicly readable"));
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shouldAutoStart() != autoStart) {
|
if (shouldAutoStart() != autoStart) {
|
||||||
_config.setProperty(PROP_AUTO_START, Boolean.toString(autoStart));
|
_config.setProperty(PROP_AUTO_START, Boolean.toString(autoStart));
|
||||||
if (autoStart)
|
if (autoStart)
|
||||||
|
@ -39,6 +39,7 @@ import net.i2p.data.DataHelper;
|
|||||||
import net.i2p.servlet.util.WriterOutputStream;
|
import net.i2p.servlet.util.WriterOutputStream;
|
||||||
import net.i2p.util.ByteCache;
|
import net.i2p.util.ByteCache;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
|
import net.i2p.util.SecureFile;
|
||||||
import net.i2p.util.SystemVersion;
|
import net.i2p.util.SystemVersion;
|
||||||
|
|
||||||
|
|
||||||
@ -113,7 +114,7 @@ class BasicServlet extends HttpServlet
|
|||||||
String rb=getInitParameter("resourceBase");
|
String rb=getInitParameter("resourceBase");
|
||||||
if (rb!=null)
|
if (rb!=null)
|
||||||
{
|
{
|
||||||
File f = new File(rb);
|
File f = new SecureFile(rb);
|
||||||
setResourceBase(f);
|
setResourceBase(f);
|
||||||
}
|
}
|
||||||
String wb = getInitParameter("warBase");
|
String wb = getInitParameter("warBase");
|
||||||
@ -124,10 +125,10 @@ class BasicServlet extends HttpServlet
|
|||||||
/**
|
/**
|
||||||
* Files are served from here
|
* Files are served from here
|
||||||
*/
|
*/
|
||||||
protected void setResourceBase(File base) throws UnavailableException {
|
protected synchronized void setResourceBase(File base) throws UnavailableException {
|
||||||
if (!base.isDirectory()) {
|
if (!base.isDirectory()) {
|
||||||
_log.log(Log.CRIT, "Configured i2psnark directory " + base + " does not exist");
|
_log.error("Configured i2psnark directory " + base + " does not exist");
|
||||||
throw new UnavailableException("Resource base does not exist: " + base);
|
//throw new UnavailableException("Resource base does not exist: " + base);
|
||||||
}
|
}
|
||||||
_resourceBase = base;
|
_resourceBase = base;
|
||||||
if (_log.shouldLog(Log.INFO))
|
if (_log.shouldLog(Log.INFO))
|
||||||
|
@ -377,8 +377,14 @@ public class I2PSnarkServlet extends BasicServlet {
|
|||||||
// end of mainsection div
|
// end of mainsection div
|
||||||
if (pageOne) {
|
if (pageOne) {
|
||||||
out.write("</div><div id=\"lowersection\">\n");
|
out.write("</div><div id=\"lowersection\">\n");
|
||||||
writeAddForm(out, req);
|
boolean canWrite;
|
||||||
writeSeedForm(out, req, sortedTrackers);
|
synchronized(this) {
|
||||||
|
canWrite = _resourceBase.canWrite();
|
||||||
|
}
|
||||||
|
if (canWrite) {
|
||||||
|
writeAddForm(out, req);
|
||||||
|
writeSeedForm(out, req, sortedTrackers);
|
||||||
|
}
|
||||||
writeConfigLink(out);
|
writeConfigLink(out);
|
||||||
// end of lowersection div
|
// end of lowersection div
|
||||||
}
|
}
|
||||||
@ -692,9 +698,22 @@ public class I2PSnarkServlet extends BasicServlet {
|
|||||||
|
|
||||||
if (total == 0) {
|
if (total == 0) {
|
||||||
out.write("<tr class=\"snarkTorrentNoneLoaded\">" +
|
out.write("<tr class=\"snarkTorrentNoneLoaded\">" +
|
||||||
"<td colspan=\"11\"><i>");
|
"<td colspan=\"11\">");
|
||||||
out.write(_t("No torrents loaded."));
|
synchronized(this) {
|
||||||
out.write("</i></td></tr>\n");
|
File dd = _resourceBase;
|
||||||
|
if (!dd.exists() && !dd.mkdirs()) {
|
||||||
|
out.write(_t("Data directory cannot be created") + ": " + DataHelper.escapeHTML(dd.toString()));
|
||||||
|
} else if (!dd.isDirectory()) {
|
||||||
|
out.write(_t("Not a directory") + ": " + DataHelper.escapeHTML(dd.toString()));
|
||||||
|
} else if (!dd.canRead()) {
|
||||||
|
out.write(_t("Unreadable") + ": " + DataHelper.escapeHTML(dd.toString()));
|
||||||
|
} else if (!dd.canWrite()) {
|
||||||
|
out.write(_t("No write permissions for data directory") + ": " + DataHelper.escapeHTML(dd.toString()));
|
||||||
|
} else {
|
||||||
|
out.write(_t("No torrents loaded."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out.write("</td></tr>\n");
|
||||||
} else /** if (snarks.size() > 1) */ {
|
} else /** if (snarks.size() > 1) */ {
|
||||||
out.write("<tfoot><tr>\n" +
|
out.write("<tfoot><tr>\n" +
|
||||||
" <th id=\"snarkTorrentTotals\" align=\"left\" colspan=\"6\">");
|
" <th id=\"snarkTorrentTotals\" align=\"left\" colspan=\"6\">");
|
||||||
|
@ -50,10 +50,6 @@
|
|||||||
</cookie-config>
|
</cookie-config>
|
||||||
</session-config>
|
</session-config>
|
||||||
|
|
||||||
<error-page>
|
|
||||||
<error-code>403</error-code>
|
|
||||||
<location>/.error</location>
|
|
||||||
</error-page>
|
|
||||||
<error-page>
|
<error-page>
|
||||||
<error-code>404</error-code>
|
<error-code>404</error-code>
|
||||||
<location>/.error</location>
|
<location>/.error</location>
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
|
2018-03-15 zzz
|
||||||
|
* i2psnark: Start even if data directory not found (ticket #2166)
|
||||||
|
|
||||||
2018-03-14 zzz
|
2018-03-14 zzz
|
||||||
* Console:
|
* Console:
|
||||||
- Hide links to webapps and eepsite if not running (ticket #2161)
|
- Hide links to webapps and eepsite if not running (ticket #2161)
|
||||||
- Hide link to /configplugins if disabled
|
- Hide link to /configplugins if disabled
|
||||||
- Add error handler to webapps (ticket #2155)
|
- Add error handler to webapps (ticket #2155)
|
||||||
* i2ptunnel: Hide links to webapps that are not runnning (ticket #2161)
|
* i2ptunnel: Hide links to webapps that are not runnning (ticket #2161)
|
||||||
* SusDNS: Translate svg image text (ticket #1749)
|
* SusiDNS: Translate svg image text (ticket #1749)
|
||||||
|
* SusiMail: Shorten URLs
|
||||||
|
|
||||||
2018-03-12 zzz
|
2018-03-12 zzz
|
||||||
* Susimail: Fix up compose.js (ticket #2176)
|
* SusiMail: Fix up compose.js (ticket #2176)
|
||||||
|
|
||||||
2018-03-11 zzz
|
2018-03-11 zzz
|
||||||
* Crypto: Add utils for renewing a cert in a keystore
|
* Crypto: Add utils for renewing a cert in a keystore
|
||||||
|
@ -18,7 +18,7 @@ public class RouterVersion {
|
|||||||
/** deprecated */
|
/** deprecated */
|
||||||
public final static String ID = "Monotone";
|
public final static String ID = "Monotone";
|
||||||
public final static String VERSION = CoreVersion.VERSION;
|
public final static String VERSION = CoreVersion.VERSION;
|
||||||
public final static long BUILD = 18;
|
public final static long BUILD = 19;
|
||||||
|
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "";
|
public final static String EXTRA = "";
|
||||||
|
Reference in New Issue
Block a user