mirror of
https://github.com/minio/minio.git
synced 2025-01-12 07:23:23 -05:00
Merge pull request #38 from fkautz/pr_out_migrating_from_unix_ts_to_time_time
This commit is contained in:
commit
3f6ddada56
@ -53,7 +53,7 @@ func (storage *Storage) StoreObject(bucket string, key string, data io.Reader) e
|
||||
etag := fmt.Sprintf("%x", sha256.Sum256(bytesBuffer.Bytes()))
|
||||
newObject.metadata = mstorage.ObjectMetadata{
|
||||
Key: key,
|
||||
SecCreated: time.Now().Unix(),
|
||||
Created: time.Now(),
|
||||
Size: size,
|
||||
ETag: etag,
|
||||
}
|
||||
@ -74,7 +74,7 @@ func (storage *Storage) StoreBucket(bucketName string) error {
|
||||
newBucket := storedBucket{}
|
||||
newBucket.metadata = mstorage.BucketMetadata{
|
||||
Name: bucketName,
|
||||
Created: time.Now().Unix(),
|
||||
Created: time.Now(),
|
||||
}
|
||||
log.Println(bucketName)
|
||||
storage.bucketdata[bucketName] = newBucket
|
||||
|
@ -19,6 +19,7 @@ package storage
|
||||
import (
|
||||
"io"
|
||||
"regexp"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Storage interface {
|
||||
@ -35,12 +36,12 @@ type Storage interface {
|
||||
|
||||
type BucketMetadata struct {
|
||||
Name string
|
||||
Created int64
|
||||
Created time.Time
|
||||
}
|
||||
|
||||
type ObjectMetadata struct {
|
||||
Key string
|
||||
SecCreated int64
|
||||
Created time.Time
|
||||
Size int
|
||||
ETag string
|
||||
}
|
||||
|
@ -56,8 +56,7 @@ func (server *minioApi) getObjectHandler(w http.ResponseWriter, req *http.Reques
|
||||
object := vars["object"]
|
||||
|
||||
metadata := server.storage.GetObjectMetadata(bucket, object)
|
||||
lastModifiedTime := time.Unix(metadata.SecCreated, 0)
|
||||
lastModified := lastModifiedTime.Format(time.RFC1123)
|
||||
lastModified := metadata.Created.Format(time.RFC1123)
|
||||
w.Header().Set("ETag", metadata.ETag)
|
||||
w.Header().Set("Last-Modified", lastModified)
|
||||
_, err := server.storage.CopyObjectToWriter(w, bucket, object)
|
||||
@ -205,7 +204,7 @@ func generateObjectsListResult(bucket string, objects []mstorage.ObjectMetadata)
|
||||
for _, object := range objects {
|
||||
content := Content{
|
||||
Key: object.Key,
|
||||
LastModified: formatDate(object.SecCreated),
|
||||
LastModified: formatDate(object.Created),
|
||||
ETag: object.ETag,
|
||||
Size: object.Size,
|
||||
StorageClass: "STANDARD",
|
||||
@ -222,7 +221,6 @@ func generateObjectsListResult(bucket string, objects []mstorage.ObjectMetadata)
|
||||
return
|
||||
}
|
||||
|
||||
func formatDate(sec int64) string {
|
||||
timeStamp := time.Unix(sec, 0)
|
||||
return timeStamp.Format("2006-01-02T15:04:05.000Z")
|
||||
func formatDate(t time.Time) string {
|
||||
return t.Format("2006-01-02T15:04:05.000Z")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user