<div dir="ltr">Can you explain this piece of code to me. It doesn&#39;t work very well to test the containing directory, as that might well be the directory holding all the modules of a particular type. For example, I have mak.conf, but it is not present in: C:\Users\Chris\Application Data\Sword\modules\comments\rawcom<div>
<br></div><div>Why are we then testing that rawcom exists and if it does accepting it?</div><div><br></div><div>SwordBookMetaData.java:<br><div><br></div><div><div>        URI location = NetUtil.lengthenURI(library, datapath);</div>
<div>        File bookDir = new File(location.getPath());</div><div>        // For some modules, the last element of the DataPath</div><div>        // is a prefix for file names.</div><div>        if (!bookDir.isDirectory()) {</div>
<div>            // Shorten it by one segment and test again.</div><div>            lastSlash = datapath.lastIndexOf(&#39;/&#39;);</div><div>            datapath = datapath.substring(0, lastSlash);</div><div>            location = NetUtil.lengthenURI(library, datapath);</div>
<div>            bookDir = new File(location.getPath());</div><div>            if (!bookDir.isDirectory()) {</div><div>                // TRANSLATOR: This indicates that the Book is only partially installed.</div><div>                throw new MissingDataFilesException(JSMsg.gettext(&quot;The book is missing its data files&quot;, cet.getValue(ConfigEntryType.INITIALS)));</div>
<div>            }</div><div>        }</div></div><div><br></div><div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 12 February 2013 19:26, DM Smith <span dir="ltr">&lt;<a href="mailto:dmsmith@crosswire.org" target="_blank">dmsmith@crosswire.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Sounds good.<div><div class="h5"><div><br><div><div>On Feb 12, 2013, at 2:18 PM, Chris Burrell &lt;<a href="mailto:chris@burrell.me.uk" target="_blank">chris@burrell.me.uk</a>&gt; wrote:</div>
<br><blockquote type="cite"><div dir="ltr">I agree with not coding against dodgy developers (although to be fair I&#39;m not entirely sure how the conf files have been left over).<div><br></div><div>But, I&#39;d like to suggest we add a line in the reading of the conf file to validate that the module data directory actually exists and is non-empty. If the directory is empty/doesn&#39;t exist, we remove the book from the returned set of installed()</div>

<div><br></div><div>Chris</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 11 February 2013 23:23, DM Smith <span dir="ltr">&lt;<a href="mailto:dmsmith@crosswire.org" target="_blank">dmsmith@crosswire.org</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Ah. I see. The JSword code (IIRC) deletes the conf first and then the files. I downloaded the module just fine and deleted it from w/in the app as well. I think we should not go out of our way for a developer that wacks parts of modules. :)<div>

<br></div><div>That said, your question regarding the error is still worthy of solving. There are many reasons that a backend might fail and it would make sense to have robust code to handle such failures.</div><div><br>
</div>
<div>In Him,</div><div><span style="white-space:pre-wrap">        </span>DM</div><div><div><div><br></div><div><br><div><br><div><div>On Feb 11, 2013, at 5:59 PM, Chris Burrell &lt;<a href="mailto:chris@burrell.me.uk" target="_blank">chris@burrell.me.uk</a>&gt; wrote:</div>

<br><blockquote type="cite"><p dir="ltr">Dm</p><p dir="ltr">The problem is that I must likely deleted the files. But not the Conf file.  <br>
Just wanted to highlight npe as we probably want to avoid having one at that stage<br>
Chris</p>
<div class="gmail_quote">On 11 Feb 2013 22:54, &quot;DM Smith&quot; &lt;<a href="mailto:dmsmith@crosswire.org" target="_blank">dmsmith@crosswire.org</a>&gt; wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<br>
On Feb 11, 2013, at 5:27 PM, Chris Burrell &lt;<a href="mailto:chris@burrell.me.uk" target="_blank">chris@burrell.me.uk</a>&gt; wrote:<br>
<br>
&gt; Hi<br>
&gt;<br>
&gt; On line 124, we have a potential NPE:<br>
&gt;<br>
&gt; state.getIdxRaf() can return a null value if for some reason we are attempting to read the cardinality of a module, but the idx file for the module is not present.<br>
&gt;<br>
&gt; In this case, I&#39;m looking at the 2babdict module, for which I have a conf file but no module files under modules/lexdict/rawld<br>
&gt;<br>
&gt; Obviously, this is an issue, but I wonder if the reading of the .conf file should identify the absence of modules and therefore<br>
&gt; a- report early to the user that something is wrong<br>
&gt; b- not show-up in the list of installed() modules<br>
<br>
The code regarding backends is in process of change, maybe done.<br>
<br>
The way the code used to work:<br>
For the list of installed books (i.e. for each conf) build an appropriate backend, which would log an error and throw an exception if the files for the module were not present and mark the module as unsupported.<br>
<br>
The problem with that model is that it is expensive on startup when lots of modules are installed. There is a Jira issue regarding improving this performance.<br>
<br>
The other problem is that it has no memory of the error and on next startup, it does the work again.<br>
<br>
It seems to me that when the module is installed, that&#39;d be a great time to validate it fully and mark it as validated.<br>
<br>
In JSword we have ReporterUtil to let the user know of events like this. It might not work in STEP as it is tied to a listener mechanism.<br>
<br>
It&#39;d be good to iterate on this to get a good solution.<br>
<br>
I&#39;m looking at 2babdict to see if I can identify the problem.<br>
<br>
In Him,<br>
        DM<br>
<br>
</blockquote></div>
</blockquote></div><br></div></div></div></div></div></blockquote></div><br></div>
</blockquote></div><br></div></div></div></div></blockquote></div><br></div>