mirror of
https://github.com/minio/minio.git
synced 2025-01-22 20:23:14 -05:00
fix: set time format right (#17402)
This commit is contained in:
parent
69f819e199
commit
0474791cf8
@ -626,11 +626,9 @@ func getInternalReplicationState(m map[string]string) ReplicationState {
|
||||
for k, v := range m {
|
||||
switch {
|
||||
case equals(k, ReservedMetadataPrefixLower+ReplicationTimestamp):
|
||||
tm, _ := time.Parse(http.TimeFormat, v)
|
||||
d.ReplicationTimeStamp = tm
|
||||
d.ReplicaTimeStamp, _ = amztime.ParseReplicationTS(v)
|
||||
case equals(k, ReservedMetadataPrefixLower+ReplicaTimestamp):
|
||||
tm, _ := time.Parse(http.TimeFormat, v)
|
||||
d.ReplicaTimeStamp = tm
|
||||
d.ReplicaTimeStamp, _ = amztime.ParseReplicationTS(v)
|
||||
case equals(k, ReservedMetadataPrefixLower+ReplicaStatus):
|
||||
d.ReplicaStatus = replication.StatusType(v)
|
||||
case equals(k, ReservedMetadataPrefixLower+ReplicationStatus):
|
||||
|
@ -25,7 +25,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
@ -1341,10 +1340,10 @@ func (x *xlMetaV2) DeleteVersion(fi FileInfo) (string, error) {
|
||||
switch fi.DeleteMarkerReplicationStatus() {
|
||||
case replication.Replica:
|
||||
ver.DeleteMarker.MetaSys[ReservedMetadataPrefixLower+ReplicaStatus] = []byte(fi.ReplicationState.ReplicaStatus)
|
||||
ver.DeleteMarker.MetaSys[ReservedMetadataPrefixLower+ReplicaTimestamp] = []byte(fi.ReplicationState.ReplicaTimeStamp.UTC().Format(http.TimeFormat))
|
||||
ver.DeleteMarker.MetaSys[ReservedMetadataPrefixLower+ReplicaTimestamp] = []byte(fi.ReplicationState.ReplicaTimeStamp.UTC().Format(time.RFC3339Nano))
|
||||
default:
|
||||
ver.DeleteMarker.MetaSys[ReservedMetadataPrefixLower+ReplicationStatus] = []byte(fi.ReplicationState.ReplicationStatusInternal)
|
||||
ver.DeleteMarker.MetaSys[ReservedMetadataPrefixLower+ReplicationTimestamp] = []byte(fi.ReplicationState.ReplicationTimeStamp.UTC().Format(http.TimeFormat))
|
||||
ver.DeleteMarker.MetaSys[ReservedMetadataPrefixLower+ReplicationTimestamp] = []byte(fi.ReplicationState.ReplicationTimeStamp.UTC().Format(time.RFC3339Nano))
|
||||
}
|
||||
}
|
||||
if !fi.VersionPurgeStatus().Empty() {
|
||||
|
@ -70,3 +70,13 @@ func ParseHeader(timeStr string) (time.Time, error) {
|
||||
}
|
||||
return time.Time{}, ErrMalformedDate
|
||||
}
|
||||
|
||||
// ParseReplicationTS parse http.TimeFormat first
|
||||
// will try time.RFC3339Nano when parse http.TimeFormat failed
|
||||
func ParseReplicationTS(str string) (time.Time, error) {
|
||||
tm, err := time.Parse(http.TimeFormat, str)
|
||||
if tm.IsZero() || err != nil {
|
||||
tm, err = time.Parse(time.RFC3339Nano, str)
|
||||
}
|
||||
return tm, err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user