Daniel Cheng wrote:
> On Tue, Oct 21, 2008 at 11:24 PM,  <nextgens at freenetproject.org> wrote:
>> Author: nextgens
>> Date: 2008-10-21 15:24:47 +0000 (Tue, 21 Oct 2008)
>> New Revision: 23014
>>
>> Modified:
>>   trunk/freenet/src/freenet/client/ArchiveManager.java
> [...]
>> Log:
>> more work on bug #71: *** IT NEEDS TESTING! ***
>> It's still not backward compatible with stable but should be 
>> forward-compatible ;)
>>
>> Modified: trunk/freenet/src/freenet/client/ArchiveManager.java
>> ===================================================================
> [...]
>> -       public void extractToCache(FreenetURI key, short archiveType, Bucket 
>> data, ArchiveContext archiveContext, ArchiveStoreContext ctx, String 
>> element, ArchiveExtractCallback callback) throws ArchiveFailureException, 
>> ArchiveRestartException {
>> +       public void extractToCache(FreenetURI key, ARCHIVE_TYPE archiveType, 
>> COMPRESSOR_TYPE ctype, Bucket data, ArchiveContext archiveContext, 
>> ArchiveStoreContext ctx, String element, ArchiveExtractCallback callback) 
>> throws ArchiveFailureException, ArchiveRestartException {
>>
>>                logMINOR = Logger.shouldLog(Logger.MINOR, this);
>>
>> @@ -249,21 +258,40 @@
>>                }
>>                if(data.size() > archiveContext.maxArchiveSize)
>>                        throw new ArchiveFailureException("Archive too big 
>> ("+data.size()+" > "+archiveContext.maxArchiveSize+")!");
>> -               if(ARCHIVE_TYPE.ZIP.metadataID ==  archiveType)
>> -                       handleZIPArchive(ctx, key, data, element, callback, 
>> gotElement, throwAtExit);
>> -               else if(ARCHIVE_TYPE.TAR.metadataID == archiveType)
>> -                       handleTARArchive(ctx, key, data, element, callback, 
>> gotElement, throwAtExit);
>> +
>> +
>> +               InputStream is = null;
>> +               try {
>> +                       if(ctype == null) {
>> +                               if(logMINOR) Logger.minor(this, "No 
>> compression");
>> +                               is = data.getInputStream();
>> +                       } else if(ctype == COMPRESSOR_TYPE.BZIP2) {
>> +                               if(logMINOR) Logger.minor(this, "dealing 
>> with BZIP2");
>> +                               is = new 
>> CBZip2InputStream(data.getInputStream());
>> +                       } else if(ctype == COMPRESSOR_TYPE.GZIP) {
>> +                               if(logMINOR) Logger.minor(this, "dealing 
>> with GZIP");
>> +                               is = new 
>> GZIPInputStream(data.getInputStream());
>> +                       } else
>> +                               throw new ArchiveFailureException("Unknown 
>> or unsupported compression algorithm "+ctype);
> 
> We can't reach the "else" cause here --
>  COMPRESSOR_TYPE.getCompressorByMetadataID()
>  give "null" when the type is unknown.
> 

It's still a good idea to throw: in case you add an other compression 
scheme (say lzma... like I have in my local WC) and you forgot to deal 
it here.

Reply via email to