Uploaded image for project: 'Commons Net'
  1. Commons Net
  2. NET-42

[net] Offset and resume not working...

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 1.4
    • None
    • FTP
    • None
    • Operating System: other
      Platform: All

    • 39076

    Description

      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??

      Attachments

        Activity

          People

            Unassigned Unassigned
            marc.aymar@nice.fi Marc
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: