You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by bw...@apache.org on 2003/05/18 01:30:34 UTC

cvs commit: maven/src/java/org/apache/maven/util HttpUtils.java

bwalding    2003/05/17 16:30:33

  Modified:    src/java/org/apache/maven/util HttpUtils.java
  Log:
  Backed out changes back to 1.21.
  
  Revision  Changes    Path
  1.26      +3 -78     maven/src/java/org/apache/maven/util/HttpUtils.java
  
  Index: HttpUtils.java
  ===================================================================
  RCS file: /home/cvs/maven/src/java/org/apache/maven/util/HttpUtils.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- HttpUtils.java	25 Apr 2003 14:20:47 -0000	1.25
  +++ HttpUtils.java	17 May 2003 23:30:33 -0000	1.26
  @@ -57,11 +57,9 @@
    */
   
   import java.io.File;
  -import java.io.FileInputStream;
   import java.io.FileOutputStream;
   import java.io.IOException;
   import java.io.InputStream;
  -import java.io.OutputStream;
   import java.net.Authenticator;
   import java.net.HttpURLConnection;
   import java.net.PasswordAuthentication;
  @@ -146,56 +144,15 @@
                                   boolean useChecksum )
           throws Exception
       {
  -        File tempFile = new File(destinationFile.getParentFile(), destinationFile.getName() + ".incomplete");
  -        
  -        //No resume at present.
  -        if (tempFile.exists()) 
  -        {
  -            tempFile.delete();
  -        
  -            if (tempFile.exists()) {
  -                throw new IOException("Unable to remove " + tempFile.getAbsolutePath());    
  -            }
  -        }
  -        
  -        
           // Get the requested file.
           getFile( url,
  -                 tempFile,
  +                 destinationFile,
                    ignoreErrors,
                    useTimestamp,
                    proxyHost,
                    proxyPort,
                    proxyUserName,
                    proxyPassword );
  -            
  -        //If it was downloaded, copy it across to the snapshot
  -        if (tempFile.exists()) {
  -            //This stupidity (not renaming) is caused by Win32 file locking stupidity.     
  -            FileOutputStream fos = null;
  -            FileInputStream fis = null;
  -            
  -            try {
  -                fis = new FileInputStream(tempFile);
  -                fos = new FileOutputStream(destinationFile);
  -                transferStream(fis, fos);
  -            } finally {
  -                try {
  -                    fis.close();
  -                } catch (Exception ex) {
  -                }
  -                try {
  -                    fos.close();
  -                } catch (Exception ex) {
  -                }
  -            }
  -            destinationFile.setLastModified(tempFile.lastModified());
  -                    
  -            if (!tempFile.delete()) {
  -                throw new IOException("Unable to delete " + tempFile.getAbsolutePath());                                   
  -            }
  -        }
  -       
   
           // Get the checksum if requested.
           if ( useChecksum )
  @@ -258,20 +215,9 @@
           //set the timestamp to the file date.
           long timestamp = 0;
           boolean hasTimestamp = false;
  -        
  -        File realDestination;
  -        String destinationFileName = destinationFile.getAbsolutePath();
  -            
  -        if (destinationFileName.endsWith(".incomplete")) {
  -            realDestination = new File(destinationFileName.substring(0, destinationFileName.length() - 11));
  -        } else {
  -            realDestination = destinationFile;
  -        }
  -        
  -        
  -        if ( useTimestamp && realDestination.exists() )
  +        if ( useTimestamp && destinationFile.exists() )
           {
  -            timestamp = realDestination.lastModified();
  +            timestamp = destinationFile.lastModified();
               hasTimestamp = true;
           }
   
  @@ -317,7 +263,6 @@
               HttpURLConnection httpConnection = (HttpURLConnection) connection;
               if ( httpConnection.getResponseCode() == HttpURLConnection.HTTP_NOT_MODIFIED )
               {
  -                System.out.println("Artifact not modified. Skipping download.");
                   return;
               }
               // test for 401 result (HTTP only)
  @@ -446,24 +391,4 @@
           file.setLastModified( modifiedTime );
           return true;
       }
  -    
  -    
  -    private static final int BUFFER_SIZE = 16384;
  -    
  -    /**
  -     * Transfers all remaining data in the input stream to the output stream
  -     * 
  -     * Neither stream will be closed at completion.
  -     **/
  -    public static void transferStream(InputStream is, OutputStream os)
  -        throws IOException {
  -        final byte[] buffer = new byte[BUFFER_SIZE];
  -        while (true) {
  -            int bytesRead = is.read(buffer, 0, buffer.length);
  -            if (bytesRead == -1)
  -                break;
  -            os.write(buffer, 0, bytesRead);
  -        }
  -    }
  -    
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org