Skip to content

ftp: add full modtime support - #5655

Merged
ivandeex merged 1 commit into
rclone:masterfrom
ivandeex:pr-ftp-modtime
Oct 21, 2021
Merged

ivandeex merged 1 commit into
rclone:masterfrom
ivandeex:pr-ftp-modtime

Conversation

@ivandeex

@ivandeex ivandeex commented Oct 3, 2021 •

Copy link
Copy Markdown
Member

Intro

The original FTP RFC had very limited support for file time which is inadequate nowadays. The LIST and NLST commands inherited their time format directly from the Unix ls utility which is optimized for humans not for strictness. Thus, they provided precise time to 1-sec resolution only for recently updated files but not for files older than one day. In fact, getting precise timestamps was generally impossible. The MLSD extension partially improved situation for directory listings. Later such extensions as MDTM and MFMT added protocol support for setting and getting time on individual files to 1sec precision. Today major FTP servers such as ProFTPd, PureFTPd, VsFTPd and Filezilla support the extensions making FTP really suitable for modern file storage.

According to RFC 3659 the MDTM command can be used to get file time with 1s precision and MFMT can modify the time. VsFTPd is enfant terrible a notable exception. Its developers instead of supporting MFMT introduced a strange, non-standard form of MDTM to set file timestamps (see the code). The form is enabled by default (search for mdtm_write in the man page to prove it). Thank gods, other FTP servers follow the standard.

What is the purpose of this change?

Currently rclone FTP client can use MLSD but lacks MDTM and MFMT. This patch adds support for these commands when advertised by FTP server. The backend will use a combination of advertised commands and caching in the rclone Object structures to provide user with time to 1 second precision if possible.

The new FTP option writing_mdtm and CLI flag --ftp-writing-mdtm will let users activate the VsFTPd quirk mentioned above. Note that by default the non-standard MDTM support is turned off for compatibility with existing applications. In future we may think about a way to detect VsFTPd on first connect and turn this on automatically. I decided to delay it for a future patch so it's out of scope for this PR.

Unit test

The rclone test suite has a number of file timestamp tests but they are activated only on backends which report time support. The new FTP unit test just verifies that precise time is supported with major FTP servers: ProFTPd, PureFTPd, VsFTPd. The main test suite will check the rest.

Was the change discussed in an issue or in the forum before?

Fixes #2384
Fixes #5283

Related to https://forum.rclone.org/t/ftp-also-check-mod-time-against-upload-time-by-default/24536/10
Related to https://forum.rclone.org/t/rclone-does-not-update-mod-time-on-destination/15858

Depends on the upstream PR jlaffaye/ftp#233 which will introduce a few API calls:

  • main time methods: GetTime and SetTime
  • informational methods to let applications query and report server capabilities: IsGetTimeSupported, IsSetTimeSupported, IsTimePreciseInList
  • the dial option DialWithWritingMDTM to activate the VsFTPd quirk

The temporary DON'T MERGE commit will be removed after jlaffaye/ftp#233 get merged. It just allows to verify changes in advance...

Checklist

  • I have read the contribution guidelines.
  • I have added tests for all changes in this PR if appropriate.
  • I have added documentation for the changes if appropriate.
  • All commit messages are in house style.
  • I'm done, this Pull Request is ready for review :-)

@ivandeex

ivandeex commented Oct 7, 2021

Copy link
Copy Markdown
Member Author

This pull request can be long waiting for upstream. I created branch iva-ftp to have ready beta in advance.

@ivandeex

Copy link
Copy Markdown
Member Author

@ncw
Now we've got https://github.com/rclone/ftp with latest fixes (the pull requests are still there waiting for jlaffaye)
so #5655 can be merged right for 1.57...
Requesting your review...

@ivandeex
ivandeex requested a review from ncw October 20, 2021 17:07
@ivandeex ivandeex modified the milestones: v1.58, v1.57 Oct 20, 2021
@ivandeex

ivandeex commented Oct 20, 2021 •

Copy link
Copy Markdown
Member Author

@ncw ncw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great - thank you :-)

@ivandeex
ivandeex merged commit 844025d into rclone:master Oct 21, 2021
@ivandeex
ivandeex deleted the pr-ftp-modtime branch October 21, 2021 11:50
lafkpages pushed a commit to lafkpages/rclone that referenced this pull request Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

backend/ftp: incomplete modtime support ftp backend time support

2 participants