added file checker, completation/size/digest
This commit is contained in:
@@ -254,6 +254,44 @@ func (hand *Handler) ListFiles(rctx *router.Context) {
|
||||
rctx.SendJSON(code, res.Files)
|
||||
}
|
||||
|
||||
func (hand *Handler) CheckFiles(rctx *router.Context) {
|
||||
|
||||
filepath, _ := rctx.GetSubpath("path")
|
||||
if filepath == "" {
|
||||
filepath = "/"
|
||||
}
|
||||
params := &fileoper.CheckFilesParams{
|
||||
Path: filepath,
|
||||
}
|
||||
err := rctx.BindQuery(params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("CheckFiles binding error: %v", err)
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
// Rigth checking
|
||||
operatorID, _ := rctx.GetString(userTag)
|
||||
opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, terms.RightWriteFiles, params.Path)
|
||||
if err != nil {
|
||||
rctx.SetStatus(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
if !opEnable {
|
||||
rctx.SetStatus(http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
// Execution of the operation
|
||||
ctx := rctx.GetContext()
|
||||
code, res, err := hand.fiop.CheckFiles(ctx, operatorID, params)
|
||||
if err != nil {
|
||||
hand.logg.Errorf("CheckFiles error: %v", err)
|
||||
rctx.SetStatus(code)
|
||||
return
|
||||
}
|
||||
rctx.SendJSON(code, res.Files)
|
||||
}
|
||||
|
||||
// GetProperty godoc
|
||||
//
|
||||
// @Summary List collections
|
||||
|
||||
Reference in New Issue
Block a user