commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 39076] New: - Offset and resume not working...
Date Thu, 23 Mar 2006 10:02:09 GMT
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=39076>.
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=39076

           Summary: Offset and resume not working...
           Product: Commons
           Version: 1.4 Final
          Platform: All
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: P2
         Component: File Upload
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: marc.aymar@nice.fi
                CC: commons-dev@jakarta.apache.org


When setting the restart offset : setRestartOffset(long offset) one would 
expect that when resuming storing the same file on the server, it will restart 
from that offset and not from beggining.

I made the follwoing change (-->><<--) in the org.apache.commons.net.io.Util 
class

public static final long copyStream(long offset, source,...

...
		try {
			-->> source.skip(offset); <<--
			while ((bytes = source.read(buffer)) != -1) {
...

This change allows to skip the bytes until the offset mark.

In the main code there is of course a need to set :
	      ftpClient.setRestartOffset(dest_file_size);
	      output = ftp.storeFileStream("filename");

dest_file_size was calculated using the following code as I haven't found a 
method return the size of the file:

	static long getSize(FTPFile[] ftpFiles, String filename){
		for(int i=0; i<ftpFiles.length;i++){
			if (ftpFiles[i].getName().equalsIgnoreCase(filename)){
				return ftpFiles[i].getSize();
			}
		}
		return -1;
	}

where ftpFiles = ftpClient.initiateListParsing().getFiles(); 

What do you think??

-- 
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.
You are on the CC list for the bug, or are watching someone who is.

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


Mime
View raw message