working commit

This commit is contained in:
2026-02-13 16:28:05 +02:00
parent e72ffda8b1
commit 04cf117632
6 changed files with 387 additions and 11 deletions
+72 -2
View File
@@ -10,8 +10,10 @@
package handler
import (
"fmt"
"io"
"mstore/app/descr"
"mstore/app/operator"
"mstore/app/router"
)
@@ -24,6 +26,20 @@ func (hand *Handler) FileInfo(rctx *router.Context) {
params := &operator.FileInfoParams{
Filepath: filepath,
}
// Rigth checking
operatorID, _ := rctx.GetString(userTag)
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadFiles, "")
if err != nil {
err := fmt.Errorf("Operation error: %v", err)
hand.SendError(rctx, err)
return
}
if !opEnable {
err := fmt.Errorf("Operation not enabled for this account")
hand.SendError(rctx, err)
return
}
// Execution of the operation
ctx := rctx.GetContext()
code, res, err := hand.oper.FileInfo(ctx, params)
if err != nil {
@@ -52,8 +68,21 @@ func (hand *Handler) PutFile(rctx *router.Context) {
ContentSize: contentSize,
Source: rctx.Request.Body,
}
// Rigth checking
operatorID, _ := rctx.GetString(userTag)
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteFiles, "")
if err != nil {
err := fmt.Errorf("Operation error: %v", err)
hand.SendError(rctx, err)
return
}
if !opEnable {
err := fmt.Errorf("Operation not enabled for this account")
hand.SendError(rctx, err)
return
}
// Execution of the operation
ctx := rctx.GetContext()
code, _, err := hand.oper.PutFile(ctx, params)
if err != nil {
hand.logg.Errorf("PutFile error: %v", err)
@@ -69,6 +98,20 @@ func (hand *Handler) GetFile(rctx *router.Context) {
params := &operator.GetFileParams{
Filepath: filepath,
}
// Rigth checking
operatorID, _ := rctx.GetString(userTag)
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadFiles, "")
if err != nil {
err := fmt.Errorf("Operation error: %v", err)
hand.SendError(rctx, err)
return
}
if !opEnable {
err := fmt.Errorf("Operation not enabled for this account")
hand.SendError(rctx, err)
return
}
// Execution of the operation
ctx := rctx.GetContext()
code, res, err := hand.oper.GetFile(ctx, params)
if err != nil {
@@ -99,6 +142,20 @@ func (hand *Handler) DeleteFile(rctx *router.Context) {
params := &operator.DeleteFileParams{
Filepath: filepath,
}
// Rigth checking
operatorID, _ := rctx.GetString(userTag)
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightWriteFiles, "")
if err != nil {
err := fmt.Errorf("Operation error: %v", err)
hand.SendError(rctx, err)
return
}
if !opEnable {
err := fmt.Errorf("Operation not enabled for this account")
hand.SendError(rctx, err)
return
}
// Execution of the operation
ctx := rctx.GetContext()
code, _, err := hand.oper.DeleteFile(ctx, params)
if err != nil {
@@ -117,8 +174,21 @@ func (hand *Handler) ListFiles(rctx *router.Context) {
params := &operator.ListFilesParams{
Filepath: filepath,
}
// Rigth checking
operatorID, _ := rctx.GetString(userTag)
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadFiles, "")
if err != nil {
err := fmt.Errorf("Operation error: %v", err)
hand.SendError(rctx, err)
return
}
if !opEnable {
err := fmt.Errorf("Operation not enabled for this account")
hand.SendError(rctx, err)
return
}
// Execution of the operation
ctx := rctx.GetContext()
code, res, err := hand.oper.ListFiles(ctx, params)
if err != nil {
hand.logg.Errorf("ListFiles error: %v", err)