Changeset cfd84bd


Ignore:
Timestamp:
Mar 15, 2018 3:50:33 PM (2 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
144147d
Parents:
1de82a68
Message:

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

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java

    r1de82a68 rcfd84bd  
    10591059        }
    10601060
     1061        // set this before we check the data dir
     1062        if (areFilesPublic() != filesPublic) {
     1063            _config.setProperty(PROP_FILES_PUBLIC, Boolean.toString(filesPublic));
     1064            _util.setFilesPublic(filesPublic);
     1065            if (filesPublic)
     1066                addMessage(_t("New files will be publicly readable"));
     1067            else
     1068                addMessage(_t("New files will not be publicly readable"));
     1069            changed = true;
     1070        }
     1071
    10611072        if (dataDir != null && !dataDir.equals(getDataDir().getAbsolutePath())) {
    10621073            dataDir = DataHelper.stripHTML(dataDir.trim());
    1063             File dd = new File(dataDir);
     1074            File dd = areFilesPublic() ? new File(dataDir) : new SecureDirectory(dataDir);
    10641075            if (!dd.isAbsolute()) {
    10651076                addMessage(_t("Data directory must be an absolute path") + ": " + dataDir);
    1066             } else if (!dd.exists()) {
    1067                 addMessage(_t("Data directory does not exist") + ": " + dataDir);
     1077            } else if (!dd.exists() && !dd.mkdirs()) {
     1078                // save this tag for now, may need it again
     1079                if (false)
     1080                    addMessage(_t("Data directory does not exist") + ": " + dataDir);
     1081                addMessage(_t("Data directory cannot be created") + ": " + dataDir);
    10681082            } else if (!dd.isDirectory()) {
    10691083                addMessage(_t("Not a directory") + ": " + dataDir);
     
    11971211            }  // reconnect || changed options
    11981212
    1199         if (areFilesPublic() != filesPublic) {
    1200             _config.setProperty(PROP_FILES_PUBLIC, Boolean.toString(filesPublic));
    1201             _util.setFilesPublic(filesPublic);
    1202             if (filesPublic)
    1203                 addMessage(_t("New files will be publicly readable"));
    1204             else
    1205                 addMessage(_t("New files will not be publicly readable"));
    1206             changed = true;
    1207         }
    1208 
    12091213        if (shouldAutoStart() != autoStart) {
    12101214            _config.setProperty(PROP_AUTO_START, Boolean.toString(autoStart));
  • apps/i2psnark/java/src/org/klomp/snark/web/BasicServlet.java

    r1de82a68 rcfd84bd  
    4040import net.i2p.util.ByteCache;
    4141import net.i2p.util.Log;
     42import net.i2p.util.SecureFile;
    4243import net.i2p.util.SystemVersion;
    4344
     
    114115        if (rb!=null)
    115116        {
    116             File f = new File(rb);
     117            File f = new SecureFile(rb);
    117118            setResourceBase(f);
    118119        }
     
    125126     *  Files are served from here
    126127     */
    127     protected void setResourceBase(File base) throws UnavailableException {
     128    protected synchronized void setResourceBase(File base) throws UnavailableException {
    128129        if (!base.isDirectory()) {
    129             _log.log(Log.CRIT, "Configured i2psnark directory " + base + " does not exist");
    130             throw new UnavailableException("Resource base does not exist: " + base);
     130            _log.error("Configured i2psnark directory " + base + " does not exist");
     131            //throw new UnavailableException("Resource base does not exist: " + base);
    131132        }
    132133        _resourceBase = base;
  • apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java

    r1de82a68 rcfd84bd  
    378378            if (pageOne) {
    379379                out.write("</div><div id=\"lowersection\">\n");
    380                 writeAddForm(out, req);
    381                 writeSeedForm(out, req, sortedTrackers);
     380                boolean canWrite;
     381                synchronized(this) {
     382                    canWrite = _resourceBase.canWrite();
     383                }
     384                if (canWrite) {
     385                    writeAddForm(out, req);
     386                    writeSeedForm(out, req, sortedTrackers);
     387                }
    382388                writeConfigLink(out);
    383389                // end of lowersection div
     
    693699        if (total == 0) {
    694700            out.write("<tr class=\"snarkTorrentNoneLoaded\">" +
    695                       "<td colspan=\"11\"><i>");
    696             out.write(_t("No torrents loaded."));
    697             out.write("</i></td></tr>\n");
     701                      "<td colspan=\"11\">");
     702            synchronized(this) {
     703                File dd = _resourceBase;
     704                if (!dd.exists() && !dd.mkdirs()) {
     705                    out.write(_t("Data directory cannot be created") + ": " + DataHelper.escapeHTML(dd.toString()));
     706                } else if (!dd.isDirectory()) {
     707                    out.write(_t("Not a directory") + ": " + DataHelper.escapeHTML(dd.toString()));
     708                } else if (!dd.canRead()) {
     709                    out.write(_t("Unreadable") + ": " + DataHelper.escapeHTML(dd.toString()));
     710                } else if (!dd.canWrite()) {
     711                    out.write(_t("No write permissions for data directory") + ": " + DataHelper.escapeHTML(dd.toString()));
     712                } else {
     713                    out.write(_t("No torrents loaded."));
     714                }
     715            }
     716            out.write("</td></tr>\n");
    698717        } else /** if (snarks.size() > 1) */ {
    699718            out.write("<tfoot><tr>\n" +
  • apps/i2psnark/web.xml

    r1de82a68 rcfd84bd  
    5252
    5353    <error-page>
    54         <error-code>403</error-code>
    55         <location>/.error</location>
    56     </error-page>
    57     <error-page>
    5854        <error-code>404</error-code>
    5955        <location>/.error</location>
  • history.txt

    r1de82a68 rcfd84bd  
     12018-03-15 zzz
     2 * i2psnark: Start even if data directory not found (ticket #2166)
     3
    142018-03-14 zzz
    25 * Console:
     
    58   - Add error handler to webapps (ticket #2155)
    69 * i2ptunnel: Hide links to webapps that are not runnning (ticket #2161)
    7  * SusDNS: Translate svg image text (ticket #1749)
     10 * SusiDNS: Translate svg image text (ticket #1749)
     11 * SusiMail: Shorten URLs
    812
    9132018-03-12 zzz
    10  * Susimail: Fix up compose.js (ticket #2176)
     14 * SusiMail: Fix up compose.js (ticket #2176)
    1115
    12162018-03-11 zzz
  • router/java/src/net/i2p/router/RouterVersion.java

    r1de82a68 rcfd84bd  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 18;
     21    public final static long BUILD = 19;
    2222
    2323    /** for example "-test" */
Note: See TracChangeset for help on using the changeset viewer.