Opened 5 years ago

Closed 21 months ago

#105 closed enhancement (wontfix)

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 (2)

comment:1 Changed 5 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?

comment:2 Changed 21 months ago by schwa

Resolution: wontfix
Status: newclosed

There hasn't been a reply for years and I don't know how to implement this consistently for download and upload (see previous comment). Therefore I close this ticket for now. Feel free to reopen the ticket if there's new information, e. g. about a server extension to change file modification times.

Note: See TracTickets for help on using tickets.