fix file timestamps

This commit is contained in:
Asim Aslam
2021-06-03 14:50:39 +01:00
parent b802791518
commit b379f1711e
3 changed files with 24 additions and 16 deletions

View File

@@ -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 {