working commit
This commit is contained in:
+36
-23
@@ -10,6 +10,7 @@
|
||||
package fileoper
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -49,31 +50,43 @@ func (oper *Operator) GetFile(ctx context.Context, operatorID string, params *Ge
|
||||
oper.iLock.WaitAndLock(resName)
|
||||
defer oper.iLock.Done(resName)
|
||||
|
||||
descrExists, fileDescr, err := oper.mdb.GetFileByCollectionName(ctx, collection, filename)
|
||||
if err != nil {
|
||||
code := http.StatusInternalServerError
|
||||
return code, res, err
|
||||
}
|
||||
if !descrExists {
|
||||
code := http.StatusNotFound
|
||||
return code, res, err
|
||||
}
|
||||
reader, err := oper.store.GetFileReader(collection, filename)
|
||||
if err != nil {
|
||||
code := http.StatusInternalServerError
|
||||
return code, res, err
|
||||
}
|
||||
res = &GetFileResult{
|
||||
ContentSize: strconv.FormatInt(fileDescr.Size, 10),
|
||||
ContentType: fileDescr.Type,
|
||||
ContentDigest: fileDescr.Checksum,
|
||||
Source: reader,
|
||||
if filename != "index.yaml" {
|
||||
descrExists, fileDescr, err := oper.mdb.GetFileByCollectionName(ctx, collection, filename)
|
||||
if err != nil {
|
||||
code := http.StatusInternalServerError
|
||||
return code, res, err
|
||||
}
|
||||
if !descrExists {
|
||||
code := http.StatusNotFound
|
||||
return code, res, err
|
||||
}
|
||||
reader, err := oper.store.GetFileReader(collection, filename)
|
||||
if err != nil {
|
||||
code := http.StatusInternalServerError
|
||||
return code, res, err
|
||||
}
|
||||
res = &GetFileResult{
|
||||
ContentSize: strconv.FormatInt(fileDescr.Size, 10),
|
||||
ContentType: fileDescr.Type,
|
||||
ContentDigest: fileDescr.Checksum,
|
||||
Source: reader,
|
||||
|
||||
ContentCreatedAt: fileDescr.CreatedAt,
|
||||
ContentCreatedBy: fileDescr.CreatedBy,
|
||||
ContentUpdatedAt: fileDescr.UpdatedAt,
|
||||
ContentUpdatedBy: fileDescr.UpdatedBy,
|
||||
ContentCreatedAt: fileDescr.CreatedAt,
|
||||
ContentCreatedBy: fileDescr.CreatedBy,
|
||||
ContentUpdatedAt: fileDescr.UpdatedAt,
|
||||
ContentUpdatedBy: fileDescr.UpdatedBy,
|
||||
}
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user