maven-wagon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: maven-wagon/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers ChecksumObserver.java
Date Tue, 19 Apr 2005 04:33:59 GMT
brett       2005/04/18 21:33:59

  Modified:    wagon-provider-api/src/main/java/org/apache/maven/wagon/observers
                        ChecksumObserver.java
  Log:
  can't remove on the fly - is called in the middle of an iterator
  
  Revision  Changes    Path
  1.15      +21 -9     maven-wagon/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/ChecksumObserver.java
  
  Index: ChecksumObserver.java
  ===================================================================
  RCS file: /home/cvs/maven-wagon/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/ChecksumObserver.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ChecksumObserver.java	19 Apr 2005 03:58:43 -0000	1.14
  +++ ChecksumObserver.java	19 Apr 2005 04:33:59 -0000	1.15
  @@ -52,6 +52,8 @@
   
       private final String extension;
   
  +    private boolean transferringChecksum = false;
  +
       static
       {
           algorithmExtensionMap.put( "MD5", ".md5" );
  @@ -92,11 +94,14 @@
        */
       public void transferStarted( TransferEvent transferEvent )
       {
  -        expectedChecksum = null;
  +        if ( !transferringChecksum )
  +        {
  +            expectedChecksum = null;
   
  -        actualChecksum = null;
  +            actualChecksum = null;
   
  -        digester.reset();
  +            digester.reset();
  +        }
       }
   
       /**
  @@ -104,11 +109,19 @@
        */
       public void transferProgress( TransferEvent transferEvent, byte[] buffer, int length
)
       {
  -        digester.update( buffer, 0, length );
  +        if ( !transferringChecksum )
  +        {
  +            digester.update( buffer, 0, length );
  +        }
       }
   
       public void transferCompleted( TransferEvent transferEvent )
       {
  +        if ( transferringChecksum )
  +        {
  +            return;
  +        }
  +
           Wagon wagon = transferEvent.getWagon();
   
           actualChecksum = encode( digester.digest() );
  @@ -119,6 +132,8 @@
   
           int type = transferEvent.getRequestType();
   
  +        transferringChecksum = true;
  +
           try
           {
               if ( type == TransferEvent.REQUEST_GET )
  @@ -130,9 +145,7 @@
   
                   File checksumFile = new File( artifactFile.getPath() + extension );
   
  -                wagon.removeTransferListener( this );
                   wagon.get( checksumResource, checksumFile );
  -                wagon.addTransferListener( this );
   
                   expectedChecksum = FileUtils.fileRead( checksumFile ).trim();
               }
  @@ -148,9 +161,7 @@
                   {
                       FileUtils.fileWrite( file.getPath(), actualChecksum );
   
  -                    wagon.removeTransferListener( this );
                       wagon.put( file, checksumResource );
  -                    wagon.addTransferListener( this );
                   }
                   finally
                   {
  @@ -175,6 +186,7 @@
           {
               IoUtils.close( inputStream );
   
  +            transferringChecksum = false;
           }
   
       }
  
  
  

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


Mime
View raw message