Opened 3 years ago

Last modified 3 years ago

#105 new enhancement

option to preserve mtime on upload and download

Reported by: ftputiluser Owned by: schwa
Priority: major Milestone:
Component: Library Version:
Keywords: Cc:


Similar to pysftp, which offers the preserve_mtime option for get and put ( and (

Right now, there is no way to use ftputil to preserve the mtime of an upload (although you may use os.utime to modify the mtime of a download, once it is downloaded). This is a big thing I need to do so help is appreciated!

Change History (1)

comment:1 Changed 3 years ago by schwa

Thank you for your suggestion.

As far as I know, there's no "inherent" way to set the modification timestamp when creating a file or directory, so you have to modify the timestamp after closing the file. For local file operations, as it would apply to, this can be done with os.utime, as you mention. If I understand correctly, you could easily add the "preserve mtime" functionality in by inheriting from FTPHost and overwriting download to call the base class method and then call os.utime on the target file.

For uploads, this is more complicated. As far as I know, there's no way in FTP to change the timestamp of a directory or file, apart from changing the timestamp implicitly by writing to the directory or file. pysftp can implement this functionality because it doesn't rely on FTP(S), but uses SFTP as the underlying protocol. FTPS is FTP over a secure connection and can only use FTP commands whereas SFTP is based on SSH and works differently. The only way to support something like preserve_mtime for uploads in ftputil would be an FTP server extension which offers an FTP command to change the timestamp. I don't know how many, if any, FTP servers support such an extension.

What do you think?

Note: See TracTickets for help on using tickets.