From 87354c7cdccc8a80d4449370385ae32cb0d40e81 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: Wed, 18 Feb 2026 23:55:55 +0200 Subject: [PATCH] working commit --- app/handler/file.go | 7 +++++++ app/operator/file.go | 1 + cmd/mstorectl/filecmd.go | 5 ++++- pkg/client/file.go | 11 ++++++++++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/handler/file.go b/app/handler/file.go index b3ed4fc..2fd52cb 100644 --- a/app/handler/file.go +++ b/app/handler/file.go @@ -239,6 +239,13 @@ func (hand *Handler) DeleteCollection(rctx *router.Context) { params := &operator.DeleteColletionParams{ Path: cpath, } + err := rctx.BindQuery(params) + if err != nil { + hand.logg.Errorf("DeleteColletion binding error: %v", err) + rctx.SetStatus(http.StatusInternalServerError) + return + } + // Rigth checking operatorID, _ := rctx.GetString(userTag) opEnable, err := hand.CheckRight(rctx.Ctx, operatorID, descr.RightReadFiles, "") diff --git a/app/operator/file.go b/app/operator/file.go index 903efa0..1944691 100644 --- a/app/operator/file.go +++ b/app/operator/file.go @@ -359,6 +359,7 @@ func (oper *Operator) ListCollections(ctx context.Context, operID string, param // DeleteColletion type DeleteColletionParams struct { Path string + IsPattern bool `params:"isPattern"` } type DeleteColletionResult struct { Files []descr.File `json:"collection,omitempty"` diff --git a/cmd/mstorectl/filecmd.go b/cmd/mstorectl/filecmd.go index b023da3..45cb89c 100644 --- a/cmd/mstorectl/filecmd.go +++ b/cmd/mstorectl/filecmd.go @@ -131,6 +131,8 @@ func (util *FileUtil) CreateCollectionCmds() *cobra.Command { Run: util.DeleteCollection, } deleteCollectionCmd.Flags().BoolVarP(&util.deleteCollectionParams.Detail, "detail", "D", false, "Show detail file information") + deleteCollectionCmd.Flags().BoolVarP(&util.deleteCollectionParams.Recursive, "recursive", "R", false, "Use path as collection pattern") + subCmd.AddCommand(deleteCollectionCmd) return subCmd @@ -428,6 +430,7 @@ func (util *FileUtil) listCollections(common *CommonFileParams, params *ListColl type DeleteCollectionParams struct { Path string Detail bool + Recursive bool } type DeleteCollectionResult struct { @@ -451,7 +454,7 @@ func (util *FileUtil) deleteCollection(common *CommonFileParams, params *DeleteC } timeout := time.Duration(common.Timeout) * time.Second ctx, _ := context.WithTimeout(context.Background(), timeout) - files, err := client.NewClient().DeleteCollection(ctx, params.Path) + files, err := client.NewClient().DeleteCollection(ctx, params.Path, params.Recursive) if err != nil { return res, err } diff --git a/pkg/client/file.go b/pkg/client/file.go index 7f6354a..6ff5bdc 100644 --- a/pkg/client/file.go +++ b/pkg/client/file.go @@ -19,6 +19,7 @@ import ( "os" "path/filepath" "strconv" + "net/url" "mstore/app/descr" "mstore/pkg/auxhttp" @@ -323,7 +324,7 @@ func (cli *Client) ListCollections(ctx context.Context, catalogURI string) ([]st return res, err } -func (cli *Client) DeleteCollection(ctx context.Context, catalogURI string) ([]descr.File, error) { +func (cli *Client) DeleteCollection(ctx context.Context, catalogURI string, isPattern bool) ([]descr.File, error) { var err error res := make([]descr.File, 0) @@ -335,6 +336,14 @@ func (cli *Client) DeleteCollection(ctx context.Context, catalogURI string) ([]d if err != nil { return res, err } + if isPattern { + values := url.Values{} + values.Add("isPattern","true") + catalogURI = catalogURI + "?" + values.Encode() + } + + + req, err := http.NewRequestWithContext(ctx, http.MethodDelete, catalogURI, nil) if err != nil { return res, err