working commit
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
package fileoper
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -49,6 +50,7 @@ func (oper *Operator) GetFile(ctx context.Context, operatorID string, params *Ge
|
||||
oper.iLock.WaitAndLock(resName)
|
||||
defer oper.iLock.Done(resName)
|
||||
|
||||
if filename != "index.yaml" {
|
||||
descrExists, fileDescr, err := oper.mdb.GetFileByCollectionName(ctx, collection, filename)
|
||||
if err != nil {
|
||||
code := http.StatusInternalServerError
|
||||
@@ -76,4 +78,15 @@ func (oper *Operator) GetFile(ctx context.Context, operatorID string, params *Ge
|
||||
}
|
||||
code := http.StatusOK
|
||||
return code, res, err
|
||||
}
|
||||
// TODO: actual chart index
|
||||
reader := io.NopCloser(bytes.NewReader(nil))
|
||||
res = &GetFileResult{
|
||||
ContentSize: strconv.FormatInt(0, 10),
|
||||
ContentType: hcMimeType,
|
||||
Source: reader,
|
||||
}
|
||||
code := http.StatusOK
|
||||
return code, res, err
|
||||
|
||||
}
|
||||
|
||||
@@ -78,6 +78,10 @@ func (oper *Operator) PutFile(ctx context.Context, operatorID string, params *Pu
|
||||
var helmMeta string
|
||||
if contentType == hcMimeType {
|
||||
helmHash, helmMeta, err = oper.store.HelmMeta(tmpname)
|
||||
if err != nil {
|
||||
code := http.StatusInternalServerError
|
||||
return code, res, err
|
||||
}
|
||||
}
|
||||
|
||||
descrExists, fileDescr, err := oper.mdb.GetFileByCollectionName(ctx, collection, filename)
|
||||
|
||||
@@ -11,6 +11,9 @@ func (store *Storage) HelmMeta(filename string) (string, string, error) {
|
||||
var err error
|
||||
var meta string
|
||||
var hash string
|
||||
|
||||
filename = store.makeTmppath(filename)
|
||||
|
||||
chart, err := loader.Load(filename)
|
||||
if err != nil {
|
||||
return meta, hash, err
|
||||
|
||||
@@ -78,7 +78,7 @@ func (store *Storage) WriteTempFile(source io.Reader) (string, int64, string, er
|
||||
var size int64
|
||||
var csum string
|
||||
|
||||
tmpName := fmt.Sprintf("%d.tmp", auxuuid.NewUUID())
|
||||
tmpName := fmt.Sprintf("%s.tmp", auxuuid.NewUUID())
|
||||
tmpPath := store.makeTmppath(tmpName)
|
||||
|
||||
tmpdirpath := store.makeTmpsubdir()
|
||||
@@ -120,7 +120,7 @@ func (store *Storage) HardlinkFile(tmpName, collection, filename string) error {
|
||||
}
|
||||
filename = store.makeFilepath(collection, filename)
|
||||
_, err = os.Stat(dirname)
|
||||
if os.IsExist(err) {
|
||||
if err == nil {
|
||||
os.Remove(filename) // TODO: safe removing
|
||||
}
|
||||
tmpName = store.makeTmppath(tmpName)
|
||||
|
||||
Reference in New Issue
Block a user