Skip to content

Improve file timestamp resolution#1882

Open
mgomez12 wants to merge 1 commit intofortra:masterfrom
mgomez12:improve-timestamp-resolution
Open

Improve file timestamp resolution#1882
mgomez12 wants to merge 1 commit intofortra:masterfrom
mgomez12:improve-timestamp-resolution

Conversation

@mgomez12
Copy link
Copy Markdown

@mgomez12 mgomez12 commented Jan 29, 2025

Currently, file timestamps returned by the SMBServer are obtained by unpacking the 10-tuple returned by os.stat(some_path). However, accessing the timestamp fields in that manner returns an integer Unix timestamp, providing 1-second resolution.

This PR changes such occurences to use named access instead (using the field st_{a/c/m}time ), which returns a float value with improved resolution.

Testing with one of my projects that uses the SMB client's listPath method:

Before

>>> c.retrieve_latest_file()
2025-01-29 09:43:25.717 | INFO     | controller:retrieve_file:39 - Retrieving latest file
2025-01-29 09:43:26.750 | INFO     | driver:retrieve_file:47 - Found new result file test.csv created at 133826174050000000

After

>>> c.retrieve_latest_file()
2025-01-29 09:44:53.474 | INFO     | controller:retrieve_file:39 - Retrieving latest file
2025-01-29 09:44:54.516 | DEBUG    | driver:retrieve_file:47 - Found new result file test.csv created at 133826174934897888

@zamlz
Copy link
Copy Markdown

zamlz commented Jan 29, 2025

I'd love these changes as well!

@anadrianmanrique anadrianmanrique added the enhancement Implemented features can be improved or revised label Feb 6, 2025
@gabrielg5 gabrielg5 added the in review This issue or pull request is being analyzed label Aug 12, 2025
@covertivy
Copy link
Copy Markdown
Contributor

Please notice the getFileTime method was moved from smbserver.py to smb.py and was renamed as well.

@anadrianmanrique anadrianmanrique removed the in review This issue or pull request is being analyzed label Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Implemented features can be improved or revised

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants