From be8c6635d217a52d189a742ee6878f2c5a24b35b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D0=B5=D0=B3=20=D0=91=D0=BE=D1=80=D0=BE=D0=B4?= =?UTF-8?q?=D0=B8=D0=BD?= Date: Fri, 20 Feb 2026 00:13:41 +0200 Subject: [PATCH] working commit --- app/operator/file.go | 63 ++++++++++++++++++++++++++++++++------------ app/router/pathc.go | 2 +- 2 files changed, 47 insertions(+), 18 deletions(-) diff --git a/app/operator/file.go b/app/operator/file.go index 469bd7e..18af2c5 100644 --- a/app/operator/file.go +++ b/app/operator/file.go @@ -299,12 +299,6 @@ func (oper *Operator) ListFiles(ctx context.Context, operID string, params *List res := &ListFilesResult{ Files: make([]descr.File, 0), } - //oper.logg.Debugf("FileList path: %s %s", params.Filepath, params.PathAs) - params.Filepath, err = cleanFilepath(params.Filepath) - if err != nil { - code := http.StatusInternalServerError - return code, res, err - } switch params.PathAs { case terms.AsRegexp: files, err := oper.listFilesWithRegex(ctx, params.Filepath) @@ -314,6 +308,17 @@ func (oper *Operator) ListFiles(ctx context.Context, operID string, params *List } res.Files = files case terms.AsPrefix: + params.Filepath, err = cleanFilepath(params.Filepath) + if err != nil { + code := http.StatusInternalServerError + return code, res, err + } + params.Filepath, err = cleanFilepath(params.Filepath) + if err != nil { + code := http.StatusInternalServerError + return code, res, err + } + files, err := oper.listFilesWithPrefix(ctx, params.Filepath) if err != nil { code := http.StatusInternalServerError @@ -321,6 +326,17 @@ func (oper *Operator) ListFiles(ctx context.Context, operID string, params *List } res.Files = files default: // Fine + params.Filepath, err = cleanFilepath(params.Filepath) + if err != nil { + code := http.StatusInternalServerError + return code, res, err + } + params.Filepath, err = cleanFilepath(params.Filepath) + if err != nil { + code := http.StatusInternalServerError + return code, res, err + } + files, err := oper.listFilesInOneCollection(ctx, params.Filepath) if err != nil { code := http.StatusInternalServerError @@ -395,11 +411,7 @@ func (oper *Operator) ListCollections(ctx context.Context, operID string, param res := &ListCollectionsResult{ Collections: make([]string, 0), } - param.Path, err = cleanFilepath(param.Path) - if err != nil { - code := http.StatusInternalServerError - return code, res, err - } + collectionList := make([]string, 0) switch param.PathAS { case terms.AsRegexp: @@ -409,12 +421,24 @@ func (oper *Operator) ListCollections(ctx context.Context, operID string, param return code, res, err } case terms.AsPrefix: + param.Path, err = cleanFilepath(param.Path) + if err != nil { + code := http.StatusInternalServerError + return code, res, err + } + collectionList, err = oper.listCollectionsWithPrefix(ctx, param.Path) if err != nil { code := http.StatusInternalServerError return code, res, err } default: + param.Path, err = cleanFilepath(param.Path) + if err != nil { + code := http.StatusInternalServerError + return code, res, err + } + collectionList, err = oper.listAllCollections(ctx) if err != nil { code := http.StatusInternalServerError @@ -520,12 +544,6 @@ func (oper *Operator) DeleteColletion(ctx context.Context, operID string, param res := &DeleteColletionResult{ Files: make([]descr.File, 0), } - param.Path, err = cleanFilepath(param.Path) - if err != nil { - code := http.StatusInternalServerError - return code, res, err - } - //oper.logg.Debugf("DeleteCollection: Use path as %s", param.PathAs) switch param.PathAs { case terms.AsRegexp: collections, err := oper.listCollectionsWithRegexp(ctx, param.Path) @@ -545,6 +563,12 @@ func (oper *Operator) DeleteColletion(ctx context.Context, operID string, param res.Files = allfiles case terms.AsPrefix: + param.Path, err = cleanFilepath(param.Path) + if err != nil { + code := http.StatusInternalServerError + return code, res, err + } + collections, err := oper.listCollectionsWithPrefix(ctx, param.Path) if err != nil { code := http.StatusInternalServerError @@ -561,6 +585,11 @@ func (oper *Operator) DeleteColletion(ctx context.Context, operID string, param } res.Files = allfiles default: // Fine + param.Path, err = cleanFilepath(param.Path) + if err != nil { + code := http.StatusInternalServerError + return code, res, err + } collection := param.Path files, err := oper.deleteFilesInCollection(ctx, collection, param.DryRun) if err != nil { diff --git a/app/router/pathc.go b/app/router/pathc.go index 7ddebba..67da777 100644 --- a/app/router/pathc.go +++ b/app/router/pathc.go @@ -65,7 +65,7 @@ func pathCompiler(path string) (string, error) { } const ( - defaultRegexp = `[a-zA-Z0-9_\.][/\-\.,a-zA-Z0-9_%=*\[\]:~]+` + defaultRegexp = `[a-zA-Z0-9_\.*][/\-\.,a-zA-Z0-9_%=*\[\]:~\$]+` ) func convertRegexp(src []byte) []byte {