From 7be9855a706d1e09504f17949a90c54cd56fb2a5 Mon Sep 17 00:00:00 2001 From: Abdullah Saglam Date: Thu, 15 Dec 2022 15:10:53 +0000 Subject: [PATCH] azureblob: implement --use-server-modtime This patch implements --use-server-modtime for the Azureblob backend. It does this by not reading the time from the metadata if the global flag is set. --- backend/azureblob/azureblob.go | 4 +++- docs/content/azureblob.md | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/backend/azureblob/azureblob.go b/backend/azureblob/azureblob.go index 80050a991..af6ff9ddd 100644 --- a/backend/azureblob/azureblob.go +++ b/backend/azureblob/azureblob.go @@ -1590,7 +1590,9 @@ func (o *Object) setMetadata(metadata map[string]string) { for k, v := range metadata { o.meta[strings.ToLower(k)] = v } - if modTime, ok := o.meta[modTimeKey]; ok { + // Set o.modTime from metadata if it exists and + // UseServerModTime isn't in use. + if modTime, ok := o.meta[modTimeKey]; !o.fs.ci.UseServerModTime && ok { when, err := time.Parse(timeFormatIn, modTime) if err != nil { fs.Debugf(o, "Couldn't parse %v = %q: %v", modTimeKey, modTime, err) diff --git a/docs/content/azureblob.md b/docs/content/azureblob.md index 1087e2577..e1ea77086 100644 --- a/docs/content/azureblob.md +++ b/docs/content/azureblob.md @@ -80,7 +80,13 @@ docs](/docs/#fast-list) for more details. The modified time is stored as metadata on the object with the `mtime` key. It is stored using RFC3339 Format time with nanosecond precision. The metadata is supplied during directory listings so -there is no overhead to using it. +there is no performance overhead to using it. + +If you wish to use the Azure standard `LastModified` time stored on +the object as the modified time, then use the `--use-server-modtime` +flag. Note that rclone can't set `LastModified`, so using the +`--update` flag when syncing is recommended if using +`--use-server-modtime`. ### Performance