Details

    • Type: Wish Wish
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Nightly Builds, 2.1
    • Fix Version/s: 2.2
    • Component/s: None
    • Labels:
      None

      Description

      A lot of modern FTP servers support time modification via MFMT.
      This is especially useful for file synchronization.

      http://www.omz13.com/downloads/draft-somers-ftp-mfxx-00.html#anchor8
      http://forum.filezilla-project.org/viewtopic.php?f=6&t=6115

      1. mftp-support.patch
        4 kB
        Shikhar Bhushan

        Activity

        Sebb made changes -
        Fix Version/s 2.2 [ 12315361 ]
        Fix Version/s 2.1 [ 12313001 ]
        Rory Winston made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Fix Version/s 2.1 [ 12313001 ]
        Resolution Fixed [ 1 ]
        Shikhar Bhushan made changes -
        Attachment mftp-support.patch [ 12405155 ]
        Shikhar Bhushan made changes -
        Attachment mfmt-support.patch [ 12405123 ]
        Shikhar Bhushan made changes -
        Attachment mfmt-support.patch [ 12405123 ]
        Shikhar Bhushan made changes -
        Field Original Value New Value
        Comment [ This is a patch for adding support for the MFMT command. I tested this against proftpd which supports the feature.


        {code:borderStyle=solid}
        Index: FTPClient.java
        ===================================================================
        --- FTPClient.java (revision 763793)
        +++ FTPClient.java (working copy)
        @@ -2402,7 +2402,29 @@
                 return null;
             }
         
        +
        + /**
        + * Issue the FTP MFMT command (not supported by all servers) which sets the last
        + * modified time of a file.
        + *
        + * The timestamp should be in the form <code>YYYYMMDDhhmmss</code>. It should also
        + * be in GMT, but not all servers honour this.
        + *
        + * An FTP server would indicate its support of this feature by including "MFMT"
        + * in its response to the FEAT command, which may be retrieved by FTPClient.features()
        + *
        + * @param pathname The file path for which last modified time is to be changed.
        + * @param timeval The timestamp to set to, in <code>YYYYMMDDhhmmss</code> format.
        + * @return true if successfully set, false if not
        + * @throws IOException if an I/O error occurs.
        + * @see <a href="http://tools.ietf.org/html/draft-somers-ftp-mfxx-04">http://tools.ietf.org/html/draft-somers-ftp-mfxx-04&lt;/a>
        + */
        + public boolean setModificationTime(String pathname, String timeval) throws IOException {
        + return (FTPReply.isPositiveCompletion(mdtm(pathname))
        + && getReplyString().contains(timeval));
        + }
         
        +
             /**
              * Set the internal buffer size.
              *
        Index: FTPCommand.java
        ===================================================================
        --- FTPCommand.java (revision 763793)
        +++ FTPCommand.java (working copy)
        @@ -70,6 +70,7 @@
             public static final int MDTM = 33;
             /** @since 2.1 */
             public static final int FEAT = 34;
        + public static final int MFMT = 35;
             
             public static final int USERNAME = USER;
             public static final int PASSWORD = PASS;
        @@ -105,9 +106,10 @@
             //public static final int HELP = HELP;
             //public static final int NOOP = NOOP;
             /** @since 2.0 */
        - public static final int MOD_TIME = MDTM;
        + public static final int GET_MOD_TIME = MDTM;
             /** @since 2.1 */
             public static final int FEATURES = FEAT;
        + public static final int SET_MOD_TIME = MFMT;
             
             // Cannot be instantiated
             private FTPCommand()
        @@ -117,7 +119,7 @@
                                                   "USER", "PASS", "ACCT", "CWD", "CDUP", "SMNT", "REIN", "QUIT", "PORT",
                                                   "PASV", "TYPE", "STRU", "MODE", "RETR", "STOR", "STOU", "APPE", "ALLO",
                                                   "REST", "RNFR", "RNTO", "ABOR", "DELE", "RMD", "MKD", "PWD", "LIST",
        - "NLST", "SITE", "SYST", "STAT", "HELP", "NOOP", "MDTM", "FEAT"
        + "NLST", "SITE", "SYST", "STAT", "HELP", "NOOP", "MDTM", "FEAT", "MFMT"
                                               };
         
             /**
        Index: FTP.java
        ===================================================================
        --- FTP.java (revision 763793)
        +++ FTP.java (working copy)
        @@ -1162,7 +1162,30 @@
             {
                 return sendCommand(FTPCommand.MDTM, file);
             }
        -
        +
        +
        + /**
        + * A convenience method to send the FTP MFMT command to the server,
        + * receive the reply, and return the reply code.
        + * <p>
        + * @param pathname The pathname for which mtime is to be changed
        + * @param timeval Timestamp in <code>YYYYMMDDhhmmss</code> format
        + * @return The reply code received from the server.
        + * @exception FTPConnectionClosedException
        + * If the FTP server prematurely closes the connection as a result
        + * of the client being idle or some other reason causing the server
        + * to send FTP reply code 421. This exception may be caught either
        + * as an IOException or independently as itself.
        + * @exception IOException If an I/O error occurs while either sending the
        + * command or receiving the server reply.
        + * @see <a href="http://tools.ietf.org/html/draft-somers-ftp-mfxx-04">http://tools.ietf.org/html/draft-somers-ftp-mfxx-04&lt;/a>
        + **/
        + public int mfmt(String pathname, String timeval) throws IOException
        + {
        + return sendCommand(FTPCommand.MFMT, timeval + " " + pathname);
        + }
        +
        +
             /***
              * A convenience method to send the FTP RNFR command to the server,
              * receive the reply, and return the reply code.
        Index: FTPClient.java
        ===================================================================
        --- FTPClient.java (revision 763793)
        +++ FTPClient.java (working copy)
        @@ -2402,8 +2402,30 @@
                 return null;
             }
         
        -
        +
             /**
        + * Issue the FTP MFMT command (not supported by all servers) which sets the last
        + * modified time of a file.
        + *
        + * The timestamp should be in the form <code>YYYYMMDDhhmmss</code>. It should also
        + * be in GMT, but not all servers honour this.
        + *
        + * An FTP server would indicate its support of this feature by including "MFMT"
        + * in its response to the FEAT command, which may be retrieved by FTPClient.features()
        + *
        + * @param pathname The file path for which last modified time is to be changed.
        + * @param timeval The timestamp to set to, in <code>YYYYMMDDhhmmss</code> format.
        + * @return true if successfully set, false if not
        + * @throws IOException if an I/O error occurs.
        + * @see <a href="http://tools.ietf.org/html/draft-somers-ftp-mfxx-04">http://tools.ietf.org/html/draft-somers-ftp-mfxx-04&lt;/a>
        + */
        + public boolean setModificationTime(String pathname, String timeval) throws IOException {
        + return (FTPReply.isPositiveCompletion(mfmt(pathname, timeval))
        + && getReplyString().contains(timeval));
        + }
        +
        +
        + /**
              * Set the internal buffer size.
              *
              * @param bufSize The size of the buffer
        Index: FTPCommand.java
        ===================================================================
        --- FTPCommand.java (revision 763793)
        +++ FTPCommand.java (working copy)
        @@ -70,6 +70,7 @@
             public static final int MDTM = 33;
             /** @since 2.1 */
             public static final int FEAT = 34;
        + public static final int MFMT = 35;
             
             public static final int USERNAME = USER;
             public static final int PASSWORD = PASS;
        @@ -105,9 +106,10 @@
             //public static final int HELP = HELP;
             //public static final int NOOP = NOOP;
             /** @since 2.0 */
        - public static final int MOD_TIME = MDTM;
        + public static final int GET_MOD_TIME = MDTM;
             /** @since 2.1 */
             public static final int FEATURES = FEAT;
        + public static final int SET_MOD_TIME = MFMT;
             
             // Cannot be instantiated
             private FTPCommand()
        @@ -117,7 +119,7 @@
                                                   "USER", "PASS", "ACCT", "CWD", "CDUP", "SMNT", "REIN", "QUIT", "PORT",
                                                   "PASV", "TYPE", "STRU", "MODE", "RETR", "STOR", "STOU", "APPE", "ALLO",
                                                   "REST", "RNFR", "RNTO", "ABOR", "DELE", "RMD", "MKD", "PWD", "LIST",
        - "NLST", "SITE", "SYST", "STAT", "HELP", "NOOP", "MDTM", "FEAT"
        + "NLST", "SITE", "SYST", "STAT", "HELP", "NOOP", "MDTM", "FEAT", "MFMT"
                                               };
         
             /**
        Index: FTP.java
        ===================================================================
        --- FTP.java (revision 763793)
        +++ FTP.java (working copy)
        @@ -1162,7 +1162,30 @@
             {
                 return sendCommand(FTPCommand.MDTM, file);
             }
        -
        +
        +
        + /**
        + * A convenience method to send the FTP MFMT command to the server,
        + * receive the reply, and return the reply code.
        + * <p>
        + * @param pathname The pathname for which mtime is to be changed
        + * @param timeval Timestamp in <code>YYYYMMDDhhmmss</code> format
        + * @return The reply code received from the server.
        + * @exception FTPConnectionClosedException
        + * If the FTP server prematurely closes the connection as a result
        + * of the client being idle or some other reason causing the server
        + * to send FTP reply code 421. This exception may be caught either
        + * as an IOException or independently as itself.
        + * @exception IOException If an I/O error occurs while either sending the
        + * command or receiving the server reply.
        + * @see <a href="http://tools.ietf.org/html/draft-somers-ftp-mfxx-04">http://tools.ietf.org/html/draft-somers-ftp-mfxx-04&lt;/a>
        + **/
        + public int mfmt(String pathname, String timeval) throws IOException
        + {
        + return sendCommand(FTPCommand.MFMT, timeval + " " + pathname);
        + }
        +
        +
             /***
              * A convenience method to send the FTP RNFR command to the server,
              * receive the reply, and return the reply code.
        Index: FTPClient.java
        ===================================================================
        --- FTPClient.java (revision 763793)
        +++ FTPClient.java (working copy)
        @@ -2402,8 +2402,30 @@
                 return null;
             }
         
        -
        +
             /**
        + * Issue the FTP MFMT command (not supported by all servers) which sets the last
        + * modified time of a file.
        + *
        + * The timestamp should be in the form <code>YYYYMMDDhhmmss</code>. It should also
        + * be in GMT, but not all servers honour this.
        + *
        + * An FTP server would indicate its support of this feature by including "MFMT"
        + * in its response to the FEAT command, which may be retrieved by FTPClient.features()
        + *
        + * @param pathname The file path for which last modified time is to be changed.
        + * @param timeval The timestamp to set to, in <code>YYYYMMDDhhmmss</code> format.
        + * @return true if successfully set, false if not
        + * @throws IOException if an I/O error occurs.
        + * @see <a href="http://tools.ietf.org/html/draft-somers-ftp-mfxx-04">http://tools.ietf.org/html/draft-somers-ftp-mfxx-04&lt;/a>
        + */
        + public boolean setModificationTime(String pathname, String timeval) throws IOException {
        + return (FTPReply.isPositiveCompletion(mfmt(pathname, timeval))
        + && getReplyString().contains(timeval));
        + }
        +
        +
        + /**
              * Set the internal buffer size.
              *
              * @param bufSize The size of the buffer
        Index: FTPCommand.java
        ===================================================================
        --- FTPCommand.java (revision 763793)
        +++ FTPCommand.java (working copy)
        @@ -70,6 +70,7 @@
             public static final int MDTM = 33;
             /** @since 2.1 */
             public static final int FEAT = 34;
        + public static final int MFMT = 35;
             
             public static final int USERNAME = USER;
             public static final int PASSWORD = PASS;
        @@ -105,9 +106,10 @@
             //public static final int HELP = HELP;
             //public static final int NOOP = NOOP;
             /** @since 2.0 */
        - public static final int MOD_TIME = MDTM;
        + public static final int GET_MOD_TIME = MDTM;
             /** @since 2.1 */
             public static final int FEATURES = FEAT;
        + public static final int SET_MOD_TIME = MFMT;
             
             // Cannot be instantiated
             private FTPCommand()
        @@ -117,7 +119,7 @@
                                                   "USER", "PASS", "ACCT", "CWD", "CDUP", "SMNT", "REIN", "QUIT", "PORT",
                                                   "PASV", "TYPE", "STRU", "MODE", "RETR", "STOR", "STOU", "APPE", "ALLO",
                                                   "REST", "RNFR", "RNTO", "ABOR", "DELE", "RMD", "MKD", "PWD", "LIST",
        - "NLST", "SITE", "SYST", "STAT", "HELP", "NOOP", "MDTM", "FEAT"
        + "NLST", "SITE", "SYST", "STAT", "HELP", "NOOP", "MDTM", "FEAT", "MFMT"
                                               };
         
             /**
        Index: FTP.java
        ===================================================================
        --- FTP.java (revision 763793)
        +++ FTP.java (working copy)
        @@ -1162,7 +1162,30 @@
             {
                 return sendCommand(FTPCommand.MDTM, file);
             }
        -
        +
        +
        + /**
        + * A convenience method to send the FTP MFMT command to the server,
        + * receive the reply, and return the reply code.
        + * <p>
        + * @param pathname The pathname for which mtime is to be changed
        + * @param timeval Timestamp in <code>YYYYMMDDhhmmss</code> format
        + * @return The reply code received from the server.
        + * @exception FTPConnectionClosedException
        + * If the FTP server prematurely closes the connection as a result
        + * of the client being idle or some other reason causing the server
        + * to send FTP reply code 421. This exception may be caught either
        + * as an IOException or independently as itself.
        + * @exception IOException If an I/O error occurs while either sending the
        + * command or receiving the server reply.
        + * @see <a href="http://tools.ietf.org/html/draft-somers-ftp-mfxx-04">http://tools.ietf.org/html/draft-somers-ftp-mfxx-04&lt;/a>
        + **/
        + public int mfmt(String pathname, String timeval) throws IOException
        + {
        + return sendCommand(FTPCommand.MFMT, timeval + " " + pathname);
        + }
        +
        +
             /***
              * A convenience method to send the FTP RNFR command to the server,
              * receive the reply, and return the reply code.
        {code} ]
        ArtemGr created issue -

          People

          • Assignee:
            Unassigned
            Reporter:
            ArtemGr
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development