[jsword-svn] r2020 - trunk/jsword/src/main/java/org/crosswire/jsword/book/install/sword

dmsmith at crosswire.org dmsmith at crosswire.org
Wed Nov 24 16:53:02 MST 2010


Author: dmsmith
Date: 2010-11-24 16:53:02 -0700 (Wed, 24 Nov 2010)
New Revision: 2020

Modified:
   trunk/jsword/src/main/java/org/crosswire/jsword/book/install/sword/AbstractSwordInstaller.java
Log:
JS-128: Delete zip file after unzip.

Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/install/sword/AbstractSwordInstaller.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/install/sword/AbstractSwordInstaller.java	2010-11-24 23:13:51 UTC (rev 2019)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/install/sword/AbstractSwordInstaller.java	2010-11-24 23:53:02 UTC (rev 2020)
@@ -246,11 +246,12 @@
 
                 yield();
 
+                URI temp = null;
                 try {
                     // TRANSLATOR: Progress label indicating the Initialization of installing of a book.
                     job.setSectionName(UserMsg.gettext("Initializing"));
 
-                    URI temp = NetUtil.getTemporaryURI("swd", ZIP_SUFFIX);
+                    temp = NetUtil.getTemporaryURI("swd", ZIP_SUFFIX);
 
                     download(job, packageDirectory, sbmd.getInitials() + ZIP_SUFFIX, temp);
 
@@ -276,6 +277,16 @@
                     job.cancel();
                 } finally {
                     job.done();
+                    // tidy up after ourselves
+                    // This is a best effort. If for some reason it does not delete now
+                    // it will automatically be deleted when the JVM exits normally.
+                    if (temp != null) {
+                        try {
+                            NetUtil.delete(temp);
+                        } catch (IOException e) {
+                            log.warn("Error deleting temp download file:"+e.getMessage());
+                        }
+                    }
                 }
             }
         };




More information about the jsword-svn mailing list