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 {
|
for k, v := range m {
|
||||||
switch {
|
switch {
|
||||||
case equals(k, ReservedMetadataPrefixLower+ReplicationTimestamp):
|
case equals(k, ReservedMetadataPrefixLower+ReplicationTimestamp):
|
||||||
tm, _ := time.Parse(http.TimeFormat, v)
|
d.ReplicaTimeStamp, _ = amztime.ParseReplicationTS(v)
|
||||||
d.ReplicationTimeStamp = tm
|
|
||||||
case equals(k, ReservedMetadataPrefixLower+ReplicaTimestamp):
|
case equals(k, ReservedMetadataPrefixLower+ReplicaTimestamp):
|
||||||
tm, _ := time.Parse(http.TimeFormat, v)
|
d.ReplicaTimeStamp, _ = amztime.ParseReplicationTS(v)
|
||||||
d.ReplicaTimeStamp = tm
|
|
||||||
case equals(k, ReservedMetadataPrefixLower+ReplicaStatus):
|
case equals(k, ReservedMetadataPrefixLower+ReplicaStatus):
|
||||||
d.ReplicaStatus = replication.StatusType(v)
|
d.ReplicaStatus = replication.StatusType(v)
|
||||||
case equals(k, ReservedMetadataPrefixLower+ReplicationStatus):
|
case equals(k, ReservedMetadataPrefixLower+ReplicationStatus):
|
||||||
|
@ -25,7 +25,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -1341,10 +1340,10 @@ func (x *xlMetaV2) DeleteVersion(fi FileInfo) (string, error) {
|
|||||||
switch fi.DeleteMarkerReplicationStatus() {
|
switch fi.DeleteMarkerReplicationStatus() {
|
||||||
case replication.Replica:
|
case replication.Replica:
|
||||||
ver.DeleteMarker.MetaSys[ReservedMetadataPrefixLower+ReplicaStatus] = []byte(fi.ReplicationState.ReplicaStatus)
|
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:
|
default:
|
||||||
ver.DeleteMarker.MetaSys[ReservedMetadataPrefixLower+ReplicationStatus] = []byte(fi.ReplicationState.ReplicationStatusInternal)
|
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() {
|
if !fi.VersionPurgeStatus().Empty() {
|
||||||
|
@ -70,3 +70,13 @@ func ParseHeader(timeStr string) (time.Time, error) {
|
|||||||
}
|
}
|
||||||
return time.Time{}, ErrMalformedDate
|
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