pytest-sftpserver icon indicating copy to clipboard operation
pytest-sftpserver copied to clipboard

Downloaded files get modified time in the future

Open gjb1002 opened this issue 5 years ago • 1 comments

I do something like

with server.serve_content({'a_dir': {'somefile.txt': "File content"}}):
    ...

If I then download "somefile.txt" with my pysftp client that I'm trying to test, the file gets a timestamp one hour ahead of now.

I believe this is because of this line

mtime = calendar.timegm(datetime.now().timetuple())

which appears in two places in the code. It takes the current local time (=CET in my case) and transforms it to a timestamp as though it were GMT, resulting in the offset. I recommend that it should call "datetime.utcnow()" instead.

gjb1002 avatar Dec 13 '19 12:12 gjb1002

Even better would be to have a way to set the modified time of the files in the structure passed to serve_content - the program I'm trying to test uses the modified time a fair bit.

gjb1002 avatar Dec 13 '19 12:12 gjb1002