You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Sebb (JIRA)" <ji...@apache.org> on 2010/07/11 13:54:57 UTC

[jira] Updated: (NET-42) [net] Offset and resume not working...

     [ https://issues.apache.org/jira/browse/NET-42?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sebb updated NET-42:
--------------------

    Component/s: FTP

> [net] Offset and resume not working...
> --------------------------------------
>
>                 Key: NET-42
>                 URL: https://issues.apache.org/jira/browse/NET-42
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 1.4
>         Environment: Operating System: other
> Platform: All
>            Reporter: Marc
>
> 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??

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.