mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-11 19:04:35 +00:00
fix file timestamps
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/micro/micro/v3/service/errors"
|
||||
log "github.com/micro/micro/v3/service/logger"
|
||||
@@ -128,6 +129,13 @@ func (e *File) Save(ctx context.Context, req *file.SaveRequest, rsp *file.SaveRe
|
||||
req.File.Project = filepath.Join(tenantId, req.File.Project)
|
||||
req.File.Path = filepath.Join(req.File.Project, req.File.Path)
|
||||
|
||||
if len(req.File.Created) == 0 {
|
||||
req.File.Created = time.Now().Format(time.RFC3339Nano)
|
||||
}
|
||||
|
||||
// set updated time
|
||||
req.File.Updated = time.Now().Format(time.RFC3339Nano)
|
||||
|
||||
// create the file
|
||||
err := e.db.Create(req.File)
|
||||
if err != nil {
|
||||
|
||||
@@ -30,12 +30,12 @@ type Record struct {
|
||||
Project string `protobuf:"bytes,1,opt,name=project,proto3" json:"project,omitempty"`
|
||||
// Path to file or folder eg. '/documents/text-files/file.txt'.
|
||||
Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"`
|
||||
// File contents. Empty for directories.
|
||||
// File contents
|
||||
Content string `protobuf:"bytes,3,opt,name=content,proto3" json:"content,omitempty"`
|
||||
// Time the file was created, number of seconds since Unix epoch
|
||||
Created int64 `protobuf:"varint,4,opt,name=created,proto3" json:"created,omitempty"`
|
||||
// Time the file was updated, number of seconds since Unix epoch
|
||||
Updated int64 `protobuf:"varint,5,opt,name=updated,proto3" json:"updated,omitempty"`
|
||||
// Time the file was created e.g 2021-05-20T13:37:21Z
|
||||
Created string `protobuf:"bytes,4,opt,name=created,proto3" json:"created,omitempty"`
|
||||
// Time the file was updated e.g 2021-05-20T13:37:21Z
|
||||
Updated string `protobuf:"bytes,5,opt,name=updated,proto3" json:"updated,omitempty"`
|
||||
// Any other associated metadata
|
||||
Metadata map[string]string `protobuf:"bytes,6,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
}
|
||||
@@ -93,18 +93,18 @@ func (x *Record) GetContent() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Record) GetCreated() int64 {
|
||||
func (x *Record) GetCreated() string {
|
||||
if x != nil {
|
||||
return x.Created
|
||||
}
|
||||
return 0
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Record) GetUpdated() int64 {
|
||||
func (x *Record) GetUpdated() string {
|
||||
if x != nil {
|
||||
return x.Updated
|
||||
}
|
||||
return 0
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Record) GetMetadata() map[string]string {
|
||||
@@ -606,9 +606,9 @@ var file_proto_file_proto_rawDesc = []byte{
|
||||
0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74,
|
||||
0x68, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x63,
|
||||
0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x63, 0x72,
|
||||
0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x72,
|
||||
0x65, 0x61, 0x74, 0x65, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64,
|
||||
0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x12,
|
||||
0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x12,
|
||||
0x36, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x06, 0x20, 0x03, 0x28,
|
||||
0x0b, 0x32, 0x1a, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2e,
|
||||
0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x6d,
|
||||
|
||||
@@ -17,12 +17,12 @@ message Record {
|
||||
string project = 1;
|
||||
// Path to file or folder eg. '/documents/text-files/file.txt'.
|
||||
string path = 2;
|
||||
// File contents. Empty for directories.
|
||||
// File contents
|
||||
string content = 3;
|
||||
// Time the file was created, number of seconds since Unix epoch
|
||||
int64 created = 4;
|
||||
// Time the file was updated, number of seconds since Unix epoch
|
||||
int64 updated = 5;
|
||||
// Time the file was created e.g 2021-05-20T13:37:21Z
|
||||
string created = 4;
|
||||
// Time the file was updated e.g 2021-05-20T13:37:21Z
|
||||
string updated = 5;
|
||||
// Any other associated metadata
|
||||
map<string,string> metadata = 6;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user