You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2006/03/06 06:12:38 UTC

DO NOT REPLY [Bug 38067] - [net] FTP - WinZip file downloads are corrupted

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38067>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38067





------- Additional Comments From tkdkid@pchome.com.tw  2006-03-06 05:12 -------
In org.apache.commons.net.ftp.FTPClient

   private boolean __storeFile(int command, String remote, InputStream local)
    throws IOException
    {
        OutputStream output;
        Socket socket;
        if ((socket = _openDataConnection_(command, remote)) == null)
            return false;
        output = new BufferedOutputStream(socket.getOutputStream(),
                                          getBufferSize()
                                          );
        if (__fileType == ASCII_FILE_TYPE)
            output = new ToNetASCIIOutputStream(output);
        // Treat everything else as binary for now
        try
        {
                             
                Util.copyStream(local, output, 2048,
                              CopyStreamEvent.UNKNOWN_STREAM_SIZE, null,
                                false);
        }
        catch (IOException e)
        {




As the code shows , the block perhaps the killer that made result we want to 
figure out.
I'm not quick sure what happen copystream do to zipfile format ,then keep move 
on the copystream method can see~~~
////////////////////////////////////////////////////////////////////
Util.copyStream(local, output, 2048,
                              CopyStreamEvent.UNKNOWN_STREAM_SIZE, null,
                                false);
////////////////////////////////////////////////////////////////////


 public static final long copyStream(InputStream source, OutputStream dest,
                                        int bufferSize, long streamSize,
                                        CopyStreamListener listener,
                                        boolean flush)
    throws CopyStreamException
    {
        int bytes;
        long total;
        byte[] buffer;

        buffer = new byte[bufferSize];
        total = 0;

        try
        {
            while ((bytes = source.read(buffer)) != -1)
            {
                // Technically, some read(byte[]) methods may return 0 and we 
cannot
                // accept that as an indication of EOF.

                if (bytes == 0)
                {
                    bytes = source.read();
                    if (bytes < 0)
                        break;
                    dest.write(bytes);
                    if(flush)
                      dest.flush();
                    ++total;
                    if (listener != null)
                        listener.bytesTransferred(total, 1, streamSize);
                    continue;
                }

                dest.write(buffer, 0, bytes);
                if(flush)
                  dest.flush();
                total += bytes;
                if (listener != null)
                    listener.bytesTransferred(total, bytes, streamSize);
            }
        }
        catch (IOException e)
        {
            throw new CopyStreamException("IOException caught while copying.",
                                          total, e);
        }

        return total;
    }



////////////////////////
I'm stupid with the IO operators , can anyone tell the property of the method .
thanks



-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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