working commit
This commit is contained in:
@@ -56,7 +56,7 @@ func (oper *Operator) FileInfo(ctx context.Context, param *FileInfoParams) (int,
|
||||
filename := path.Base(xfilepath)
|
||||
collection := path.Dir(xfilepath)
|
||||
|
||||
exist, fileDescr, err := oper.mdb.GetFileByCollection(ctx, collection, filename)
|
||||
exist, fileDescr, err := oper.mdb.GetFileByCollectionName(ctx, collection, filename)
|
||||
if err != nil {
|
||||
code := http.StatusInternalServerError
|
||||
return code, res, err
|
||||
@@ -86,6 +86,7 @@ type PutFileResult struct{}
|
||||
|
||||
const defaultContentType = "application/octet-stream"
|
||||
|
||||
// TODO: checking catalog and file names conflict
|
||||
func (oper *Operator) PutFile(ctx context.Context, param *PutFileParams) (int, *PutFileResult, error) {
|
||||
var err error
|
||||
res := &PutFileResult{}
|
||||
@@ -120,7 +121,7 @@ func (oper *Operator) PutFile(ctx context.Context, param *PutFileParams) (int, *
|
||||
return code, res, err
|
||||
}
|
||||
|
||||
descrExists, fileDescr, err := oper.mdb.GetFileByCollection(ctx, collection, filename)
|
||||
descrExists, fileDescr, err := oper.mdb.GetFileByCollectionName(ctx, collection, filename)
|
||||
if err != nil {
|
||||
code := http.StatusInternalServerError
|
||||
return code, res, err
|
||||
@@ -189,7 +190,7 @@ func (oper *Operator) GetFile(ctx context.Context, param *GetFileParams) (int, *
|
||||
filename := path.Base(xfilepath)
|
||||
collection := path.Dir(xfilepath)
|
||||
|
||||
descrExists, fileDescr, err := oper.mdb.GetFileByCollection(ctx, collection, filename)
|
||||
descrExists, fileDescr, err := oper.mdb.GetFileByCollectionName(ctx, collection, filename)
|
||||
if err != nil {
|
||||
code := http.StatusInternalServerError
|
||||
return code, res, err
|
||||
@@ -232,13 +233,13 @@ func (oper *Operator) DeleteFile(ctx context.Context, param *DeleteFileParams) (
|
||||
filename := path.Base(xfilepath)
|
||||
collection := path.Dir(xfilepath)
|
||||
|
||||
exist, _, err := oper.mdb.GetFileByCollection(ctx, collection, filename)
|
||||
exist, _, err := oper.mdb.GetFileByCollectionName(ctx, collection, filename)
|
||||
if err != nil {
|
||||
code = http.StatusInternalServerError
|
||||
return code, res, err
|
||||
}
|
||||
if exist {
|
||||
err = oper.mdb.DeleteFileByCollection(ctx, collection, filename)
|
||||
err = oper.mdb.DeleteFileByCollectionName(ctx, collection, filename)
|
||||
if err != nil {
|
||||
code = http.StatusInternalServerError
|
||||
return code, res, err
|
||||
@@ -258,12 +259,14 @@ type ListFilesParams struct {
|
||||
}
|
||||
type ListFilesResult struct {
|
||||
Files []descr.File `json:"files,omitempty"`
|
||||
//Catalogs []string `json:"files,omitempty"`
|
||||
}
|
||||
|
||||
func (oper *Operator) ListFiles(ctx context.Context, param *ListFilesParams) (int, *ListFilesResult, error) {
|
||||
var err error
|
||||
res := &ListFilesResult{
|
||||
Files: make([]descr.File, 0),
|
||||
//Catalogs: make([]string, 0)
|
||||
}
|
||||
|
||||
// TODO: convert file path to a unified and secure state
|
||||
|
||||
Reference in New Issue
Block a user