[jsword-svn] jsword/java/jsword/org/crosswire/jsword/book/install/sword s

jswordcvs at crosswire.org jswordcvs at crosswire.org
Tue Jan 25 17:57:35 MST 2005


Update of /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/install/sword
In directory www.crosswire.org:/tmp/cvs-serv4948/java/jsword/org/crosswire/jsword/book/install/sword

Modified Files:
	HttpSwordInstaller.java AbstractSwordInstaller.java 
Log Message:
Fixed a couple of bugs.

Index: AbstractSwordInstaller.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/install/sword/AbstractSwordInstaller.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** AbstractSwordInstaller.java	24 Jan 2005 23:28:01 -0000	1.3
--- AbstractSwordInstaller.java	26 Jan 2005 00:57:33 -0000	1.4
***************
*** 28,32 ****
  import org.crosswire.jsword.book.install.InstallException;
  import org.crosswire.jsword.book.install.Installer;
- import org.crosswire.jsword.book.sword.ModuleType;
  import org.crosswire.jsword.book.sword.SwordBookDriver;
  import org.crosswire.jsword.book.sword.SwordBookMetaData;
--- 28,31 ----
***************
*** 73,106 ****
  
      /* (non-Javadoc)
!      * @see org.crosswire.jsword.book.install.Installer#toLocalURL(org.crosswire.jsword.book.BookMetaData)
       */
!     public URL toLocalURL(BookMetaData bmd)
      {
!         File fulldir = toLocalDirectory(bmd);
  
          try
          {
!             return new URL(NetUtil.PROTOCOL_FILE, null, fulldir.getAbsolutePath());
          }
          catch (MalformedURLException ex)
          {
!             log.error("Failed to create URL for file: "+fulldir, ex); //$NON-NLS-1$
              assert false;
!             return null;
          }
-     }
- 
-     /* (non-Javadoc)
-      * @see org.crosswire.jsword.book.install.Installer#isNewer(org.crosswire.jsword.book.BookMetaData)
-      */
-     public boolean isNewer(BookMetaData bmd)
-     {
-         URL local = toLocalURL(bmd);
- 
-         SwordBookMetaData sbmd = (SwordBookMetaData) bmd;
-         URL conf = NetUtil.lengthenURL(local, sbmd.getDiskName() + SwordConstants.EXTENSION_CONF);
  
          URL remote = toRemoteURL(bmd);
!         return NetUtil.isNewer(remote, conf);
      }
  
--- 72,100 ----
  
      /* (non-Javadoc)
!      * @see org.crosswire.jsword.book.install.Installer#isNewer(org.crosswire.jsword.book.BookMetaData)
       */
!     public boolean isNewer(BookMetaData bmd)
      {
!         SwordBookMetaData sbmd = (SwordBookMetaData) bmd;
!         File dldir = SwordBookDriver.getDownloadDir();
! 
!         File confdir = new File(dldir, SwordConstants.DIR_CONF);
!         File conf = new File(confdir, sbmd.getDiskName() + SwordConstants.EXTENSION_CONF);
  
+         URL configurl = null;
          try
          {
!             configurl = new URL(NetUtil.PROTOCOL_FILE, null, conf.getAbsolutePath());
!     
          }
          catch (MalformedURLException ex)
          {
!             log.error("Failed to create URL for file: " + conf, ex); //$NON-NLS-1$
              assert false;
!             return false;
          }
  
          URL remote = toRemoteURL(bmd);
!         return NetUtil.isNewer(remote, configurl);
      }
  
***************
*** 165,185 ****
                      job.setProgress(Msg.JOB_INIT.toString());
  
-                     URL desturl = toLocalURL(sbmd);
-                     NetUtil.makeDirectory(desturl);
- 
                      URL temp = NetUtil.getTemporaryURL("swd", ZIP_SUFFIX); //$NON-NLS-1$
  
                      download(job, directory + '/' + PACKAGE_DIR, sbmd.getInitials() + ZIP_SUFFIX, temp);
  
-                     IOUtil.unpackZip(NetUtil.getAsFile(temp), desturl);
- 
                      File dldir = SwordBookDriver.getDownloadDir();
!                     job.setProgress(Msg.JOB_CONFIG.toString());
!                     File confdir = new File(dldir, SwordConstants.DIR_CONF);
!                     confdir.mkdirs();
!                     File conf = new File(confdir, sbmd.getDiskName() + SwordConstants.EXTENSION_CONF);
!                     URL configurl = new URL(NetUtil.PROTOCOL_FILE, null, conf.getAbsolutePath());
!                     sbmd.save(configurl);
  
                      SwordBookDriver.registerNewBook(sbmd, dldir);
                  }
--- 159,170 ----
                      job.setProgress(Msg.JOB_INIT.toString());
  
                      URL temp = NetUtil.getTemporaryURL("swd", ZIP_SUFFIX); //$NON-NLS-1$
  
                      download(job, directory + '/' + PACKAGE_DIR, sbmd.getInitials() + ZIP_SUFFIX, temp);
  
                      File dldir = SwordBookDriver.getDownloadDir();
!                     IOUtil.unpackZip(NetUtil.getAsFile(temp), dldir);
  
+                     job.setProgress(Msg.JOB_CONFIG.toString());
                      SwordBookDriver.registerNewBook(sbmd, dldir);
                  }
***************
*** 211,215 ****
          {
              URL scratchfile = getCachedIndexFile();
!             download(job, LIST_DIR + '/' + directory, FILE_LIST_GZ, scratchfile);
              loaded = false;
          }
--- 196,200 ----
          {
              URL scratchfile = getCachedIndexFile();
!             download(job, directory + '/' + LIST_DIR, FILE_LIST_GZ, scratchfile);
              loaded = false;
          }
***************
*** 366,370 ****
          try
          {
!             URL scratchdir = Project.instance().getTempScratchSpace(getTempFileExtension(host, directory), false);
              return NetUtil.lengthenURL(scratchdir, FILE_LIST_GZ);
          }
--- 351,355 ----
          try
          {
!             URL scratchdir = Project.instance().getTempScratchSpace(getTempFileExtension(host, directory), true);
              return NetUtil.lengthenURL(scratchdir, FILE_LIST_GZ);
          }
***************
*** 383,408 ****
      }
  
-     /**
-      * Get a local directory to which a book is installed
-      */
-     protected File toLocalDirectory(BookMetaData bmd)
-     {
-         if (!(bmd instanceof SwordBookMetaData))
-         {
-             assert false;
-             return null;
-         }
- 
-         SwordBookMetaData sbmd = (SwordBookMetaData) bmd;
- 
-         ModuleType type = sbmd.getModuleType();
-         String modpath = type.getInstallDirectory();
-         String destname = modpath + '/' + sbmd.getDiskName();
- 
-         File dldir = SwordBookDriver.getDownloadDir();
-         File moddir = new File(dldir, SwordConstants.DIR_DATA);
-         return new File(moddir, destname);
-     }
- 
      /* (non-Javadoc)
       * @see java.lang.Object#equals(java.lang.Object)
--- 368,371 ----

Index: HttpSwordInstaller.java
===================================================================
RCS file: /cvs/jsword/jsword/java/jsword/org/crosswire/jsword/book/install/sword/HttpSwordInstaller.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** HttpSwordInstaller.java	24 Jan 2005 23:28:27 -0000	1.14
--- HttpSwordInstaller.java	26 Jan 2005 00:57:33 -0000	1.15
***************
*** 80,84 ****
          try
          {
!             URL url = new URL("http://" + host + dir + '/' + file); //$NON-NLS-1$
              copy(job, url, dest);
          }
--- 80,84 ----
          try
          {
!             URL url = new URL(NetUtil.PROTOCOL_HTTP, host, dir + '/' + file); //$NON-NLS-1$
              copy(job, url, dest);
          }



More information about the jsword-svn mailing list