pythonsftpparamikolast-modified

paramiko - How can I refresh the modified date of a file on the SFTP server automatically?


I have a file on the SFTP server that should be imported with paramiko package on certain conditions. Until these conditions aren't fulfilled, this file should stay on the server unimported, but its modified date shoud be updated, so that this date should be always bigger than the time, at which file was checked by my import program.

I read the documentation for the package but didn't found any function that could do this.


Solution

  • There's the utime method:

     utime(path, times)
    

    Set the access and modified times of the file specified by path. If times is None, then the file’s access and modified times are set to the current time. Otherwise, times must be a 2-tuple of numbers, of the form (atime, mtime), which is used to set the access and modified times, respectively.