[jsword-devel] SwordInstaller bug

DM Smith jsword-devel@crosswire.org
Fri, 26 Mar 2004 22:31:09 -0500


This is a multi-part message in MIME format.

------=_NextPart_000_117a_70a3_6b66
Content-Type: text/plain; format=flowed

I found a subtle bug in SwordInstaller.
The private variable "loaded" governs if the cache of BookMetaDatas has been 
loaded.
It should only be set to true if the file is found and is loaded. In a 
recent change, the variable was now set if the method was called, even if 
the file had not been downloaded. But that is not the subtle bug.

Let's say that an announcement comes out that there are new books and you 
went and refreshed the list. Well the file would be downloaded but it would 
not be read into core. The user would have to restart the application to get 
the new data. This has been the case for a while.

To solve this problem I merely set loaded = false after the download 
happens. This also happens to solve the first problem as well. However, I 
changed the code to set loaded only if the file existed and was loaded.

_________________________________________________________________
Get tax tips, tools and access to IRS forms – all in one place at MSN Money! 
http://moneycentral.msn.com/tax/home.asp

------=_NextPart_000_117a_70a3_6b66
Content-Type: text/plain; name="patchcached.txt"; format=flowed
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="patchcached.txt"

Index: 
java/jsword/org/crosswire/jsword/book/install/sword/SwordInstaller.java
===================================================================
retrieving revision 1.9
diff -u -r1.9 SwordInstaller.java
--- 
java/jsword/org/crosswire/jsword/book/install/sword/SwordInstaller.java	26 
Mar 2004 19:32:09 -0000	1.9
+++ 
java/jsword/org/crosswire/jsword/book/install/sword/SwordInstaller.java	27 
Mar 2004 03:32:50 -0000
@@ -164,6 +164,7 @@
     {
         URL scratchfile = getCachedIndexFile();
         download(host, USERNAME, PASSWORD, directory, FILE_LIST_GZ, 
scratchfile);
+        loaded = false;
     }

     /**
@@ -242,6 +243,7 @@
                 tin.close();
                 gin.close();
                 in.close();
+                loaded = true;
             }
             catch (IOException ex)
             {
@@ -249,7 +251,6 @@
             }
         }

-        loaded = true;
     }

     /**


------=_NextPart_000_117a_70a3_6b66--