Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replicate: Send source modtime in time nano format #1428

Merged
merged 1 commit into from
Dec 17, 2020

Conversation

vadmeste
Copy link
Member

If we already have a time with nano precision, let's send it the server.

The purpose of this PR is to fix minio/mc#3532

If we already have a time with nano precision, let's send it the server.
@harshavardhana
Copy link
Member

This would require server changes as well to parse with RFC3339Nano

@harshavardhana harshavardhana merged commit 3baf9ea into minio:master Dec 17, 2020
@harshavardhana
Copy link
Member

git diff
diff --git a/cmd/bucket-replication.go b/cmd/bucket-replication.go
index a5071df94..fef2e0d0e 100644
--- a/cmd/bucket-replication.go
+++ b/cmd/bucket-replication.go
@@ -287,7 +287,7 @@ func getCopyObjMetadata(oi ObjectInfo, dest replication.Destination) map[string]
        if oi.UserTags != "" {
                meta[xhttp.AmzObjectTagging] = oi.UserTags
        }
-       meta[xhttp.MinIOSourceMTime] = oi.ModTime.Format(time.RFC3339)
+       meta[xhttp.MinIOSourceMTime] = oi.ModTime.Format(time.RFC3339Nano)
        meta[xhttp.MinIOSourceETag] = oi.ETag
        meta[xhttp.AmzBucketReplicationStatus] = replication.Replica.String()
        return meta
@@ -330,7 +330,7 @@ func putReplicationOpts(ctx context.Context, dest replication.Destination, objIn
                putOpts.Mode = rmode
        }
        if retainDateStr, ok := objInfo.UserDefined[xhttp.AmzObjectLockRetainUntilDate]; ok {
-               rdate, err := time.Parse(time.RFC3339, retainDateStr)
+               rdate, err := time.Parse(time.RFC3339Nano, retainDateStr)
                if err != nil {
                        return
                }
diff --git a/cmd/object-api-options.go b/cmd/object-api-options.go
index a89c004c5..a793e331b 100644
--- a/cmd/object-api-options.go
+++ b/cmd/object-api-options.go
@@ -187,7 +187,7 @@ func delOpts(ctx context.Context, r *http.Request, bucket, object string) (opts
 
        mtime := strings.TrimSpace(r.Header.Get(xhttp.MinIOSourceMTime))
        if mtime != "" {
-               opts.MTime, err = time.Parse(time.RFC3339, mtime)
+               opts.MTime, err = time.Parse(time.RFC3339Nano, mtime)
                if err != nil {
                        return opts, InvalidArgument{
                                Bucket: bucket,

@vadmeste
Copy link
Member Author

This would require server changes as well to parse with RFC3339Nano

You don't have to do that, as per I tested, you can parse a string nano time with RFC3339 alone without losing any information.

@harshavardhana
Copy link
Member

You don't have to do that, as per I tested, you can parse a string nano time with RFC3339 alone without losing any information.

I would double test it once @vadmeste RFC3339 specifically skils nanosecond precision so if we are saving this information on disk if we need it we should make sure we have it.

@vadmeste
Copy link
Member Author

I would double test it once @vadmeste RFC3339 specifically skils nanosecond precision so if we are saving this information on disk if we need it we should make sure we have it.

-       meta[xhttp.MinIOSourceMTime] = oi.ModTime.Format(time.RFC3339)
+       meta[xhttp.MinIOSourceMTime] = oi.ModTime.Format(time.RFC3339Nano)

Oh yes, I didn't see that part. What I wanted to say is that RFC3339 can parse a date/time with nano precision, will send a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mc diff display different state of file in the replicated bucket
3 participants