From 397c0f872a3707143589cf806137263b892f8867 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Tue, 14 Jul 2026 12:15:09 +0100 Subject: [PATCH] azurefiles: fix incorrect modtime after uploading a file or setting its modtime Update and SetModTime kept the caller's full nanosecond precision modtime in memory while the server stores SMB LastWriteTime with 100 ns (FILETIME) precision, so until the object was re-read the modtime did not match what a fresh listing would report. This broke wrappers which compare exact modtimes, such as the hasher backend's fingerprint and the VFS cache. Truncate the modtime to 100 ns precision to match what the server stores. --- backend/azurefiles/azurefiles.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/backend/azurefiles/azurefiles.go b/backend/azurefiles/azurefiles.go index ba49e7850..db0b9262a 100644 --- a/backend/azurefiles/azurefiles.go +++ b/backend/azurefiles/azurefiles.go @@ -58,6 +58,9 @@ const ( maxFileSize = 4 * fs.Tebi defaultChunkSize = 4 * fs.Mebi storageDefaultBaseURL = "file.core.windows.net" + // smbTimePrecision is the precision the server stores + // modtimes with (100 ns FILETIME ticks) + smbTimePrecision = 100 * time.Nanosecond ) func init() { @@ -598,7 +601,10 @@ func (o *Object) SetModTime(ctx context.Context, t time.Time) error { if err != nil { return fmt.Errorf("unable to set modTime: %w", err) } - o.modTime = t + // Truncate to the precision the server stores the modtime with + // to keep the in-memory modtime identical to the one a fresh + // listing returns. + o.modTime = t.Truncate(smbTimePrecision) return nil } @@ -769,10 +775,12 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op return fmt.Errorf("update: failed to set properties: %w", err) } - // Make sure Object is in sync + // Make sure Object is in sync, truncating the modtime to the + // precision the server stores it with so it is identical to the + // one a fresh listing returns o.size = size o.md5 = md5Hash - o.modTime = modTime + o.modTime = modTime.Truncate(smbTimePrecision) o.contentType = contentType return nil }