From df60e6323c07a20de08c73839c67aa5f44e141e4 Mon Sep 17 00:00:00 2001 From: database64128 Date: Fri, 21 May 2021 23:01:32 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20GCS:=20Clean=20up=20time=20forma?= =?UTF-8?q?t=20constants?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/googlecloudstorage/googlecloudstorage.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/backend/googlecloudstorage/googlecloudstorage.go b/backend/googlecloudstorage/googlecloudstorage.go index 45fbc66d7..7b7cc5297 100644 --- a/backend/googlecloudstorage/googlecloudstorage.go +++ b/backend/googlecloudstorage/googlecloudstorage.go @@ -51,8 +51,7 @@ import ( const ( rcloneClientID = "202264815644.apps.googleusercontent.com" rcloneEncryptedClientSecret = "Uj7C9jGfb9gmeaV70Lh058cNkWvepr-Es9sBm0zdgil7JaOWF1VySw" - timeFormatIn = time.RFC3339 - timeFormatOut = time.RFC3339Nano + timeFormat = time.RFC3339Nano metaMtime = "mtime" // key to store mtime in metadata metaMtimeGsutil = "goog-reserved-file-mtime" // key used by GSUtil to store mtime in metadata listChunks = 1000 // chunk size to read directory listings @@ -922,7 +921,7 @@ func (o *Object) setMetaData(info *storage.Object) { // read mtime out of metadata if available mtimeString, ok := info.Metadata[metaMtime] if ok { - modTime, err := time.Parse(timeFormatIn, mtimeString) + modTime, err := time.Parse(timeFormat, mtimeString) if err == nil { o.modTime = modTime return @@ -942,7 +941,7 @@ func (o *Object) setMetaData(info *storage.Object) { } // Fallback to the Updated time - modTime, err := time.Parse(timeFormatIn, info.Updated) + modTime, err := time.Parse(timeFormat, info.Updated) if err != nil { fs.Logf(o, "Bad time decode: %v", err) } else { @@ -999,7 +998,7 @@ func (o *Object) ModTime(ctx context.Context) time.Time { // Returns metadata for an object func metadataFromModTime(modTime time.Time) map[string]string { metadata := make(map[string]string, 1) - metadata[metaMtime] = modTime.Format(timeFormatOut) + metadata[metaMtime] = modTime.Format(timeFormat) metadata[metaMtimeGsutil] = strconv.FormatInt(modTime.Unix(), 10) return metadata } @@ -1015,7 +1014,7 @@ func (o *Object) SetModTime(ctx context.Context, modTime time.Time) (err error) if object.Metadata == nil { object.Metadata = make(map[string]string, 1) } - object.Metadata[metaMtime] = modTime.Format(timeFormatOut) + object.Metadata[metaMtime] = modTime.Format(timeFormat) object.Metadata[metaMtimeGsutil] = strconv.FormatInt(modTime.Unix(), 10) // Copy the object to itself to update the metadata // Using PATCH requires too many permissions