Timestamp Issue
TLDR - Quick Summary
Problem: In SFTP Gateway 3.2.1 and earlier, files uploaded to Blob Storage outside SFTP Gateway show the current date and time in SFTP clients
Cause: SFTP Gateway reads timestamps from its own blob metadata, which those files don't have
Fix: Upgrade to SFTP Gateway 3.3.0 or later. Files without SFTP Gateway metadata then show the blob's own Last Modified date
Related: Client "preserve timestamps" writes are a separate behavior, configurable from 3.9.0
Overview
In SFTP Gateway 3.2.1 and earlier, SFTP clients show the current date and time for files that were uploaded to Blob Storage by other means, such as the Azure Portal, Azure Storage Explorer or AzCopy, or that were in the container before SFTP Gateway was installed. These timestamps change to the current time every time the listing refreshes. Files uploaded through SFTP Gateway show their correct timestamps.
SFTP Gateway 3.3.0 fixed this. If you see this behavior, check your version and upgrade.
How SFTP Gateway determines file timestamps
SFTP Gateway stores a file's modified, created and accessed times in blob metadata (mtime, ctime and atime) when it uploads the file, and when an SFTP client sets the file's timestamp.
When it lists a file, SFTP Gateway uses:
- Its own timestamp metadata, when the blob has it
- Otherwise, the blob's own Last modified and Creation time properties
For example, a file uploaded with the Azure Portal shows the same date the portal shows as Last modified.
Folders work the same way:
- In a storage account without hierarchical namespace, a folder is part of the blob names, and shows the container's Last Modified date
- In a storage account with hierarchical namespace (HNS) enabled, a folder shows the directory's own Last Modified date (SFTP Gateway 3.7.2 and later)
Timestamps from "preserve timestamps" uploads
The behavior above only affects how timestamps are displayed. A separate behavior applies when an SFTP client has a "preserve timestamps" option enabled, for example FileZilla's Preserve timestamps of transferred files. With that option, the client asks SFTP Gateway to set the file's original timestamp, and SFTP Gateway writes it to the blob's metadata.
From SFTP Gateway 3.9.0, you can stop SFTP Gateway from writing client-set timestamps to Blob Storage:
features.file-system.azure.ignore-client-set-times=true
For Azure File Share cloud connections, use features.file-system.azure-file-share.ignore-client-set-times=true.
With this setting, SFTP Gateway still accepts the client's request but writes nothing to the blob. The file keeps its upload time. See Application Properties for how to change settings.