working commit

This commit is contained in:
2026-02-19 11:55:17 +02:00
parent 1fd55521de
commit bb0f58f46c
37 changed files with 231 additions and 150 deletions
+1 -1
View File
@@ -4,10 +4,10 @@ import (
"context"
"fmt"
"mstore/app/descr"
"mstore/pkg/auxpwd"
"mstore/pkg/auxtool"
"mstore/pkg/auxuuid"
"mstore/pkg/descr"
)
type CreateAccountParams struct {
+65 -17
View File
@@ -20,9 +20,10 @@ import (
"strconv"
"strings"
"mstore/app/descr"
"mstore/pkg/auxtool"
"mstore/pkg/auxuuid"
"mstore/pkg/descr"
"mstore/pkg/terms"
)
// FileInfo
@@ -358,8 +359,8 @@ func (oper *Operator) ListCollections(ctx context.Context, operID string, param
// DeleteColletion
type DeleteColletionParams struct {
Path string
IsPattern bool `params:"isPattern"`
Path string
PathAs string `param:"pathAs"`
}
type DeleteColletionResult struct {
Files []descr.File `json:"collection,omitempty"`
@@ -375,24 +376,71 @@ func (oper *Operator) DeleteColletion(ctx context.Context, operID string, param
code := http.StatusInternalServerError
return code, res, err
}
fileDescrs, err := oper.mdb.ListFilesByCollection(ctx, param.Path)
if err != nil {
code := http.StatusInternalServerError
return code, res, err
}
// TODO: transaction
for _, file := range fileDescrs {
err = oper.store.DeleteFile(file.Collection, file.Name)
if err != nil {
oper.logg.Warningf("%v", err)
err = nil
}
err = oper.mdb.DeleteFileByCollectionName(ctx, file.Collection, file.Name)
oper.logg.Debugf("=== Use path as %s", param.PathAs)
switch terms.PathAs(param.PathAs) {
case terms.AsPrefix:
fileDescrs, err := oper.mdb.ListAllFiles(ctx)
if err != nil {
code := http.StatusInternalServerError
return code, res, err
}
res.Files = append(res.Files, file)
collMap := make(map[string]bool)
for _, item := range fileDescrs {
_, exists := collMap[item.Collection]
if !exists {
collMap[item.Collection] = true
}
}
collections := make([]string, len(collMap))
for key, _ := range collMap {
collections = append(collections, key)
}
for _, collection := range collections {
if strings.HasPrefix(collection, param.Path) {
fileDescrs, err := oper.mdb.ListFilesByCollection(ctx, collection)
if err != nil {
code := http.StatusInternalServerError
return code, res, err
}
// TODO: transaction
for _, file := range fileDescrs {
err = oper.store.DeleteFile(file.Collection, file.Name)
if err != nil {
oper.logg.Warningf("%v", err)
err = nil
}
err = oper.mdb.DeleteFileByCollectionName(ctx, file.Collection, file.Name)
if err != nil {
code := http.StatusInternalServerError
return code, res, err
}
res.Files = append(res.Files, file)
}
}
}
default:
fileDescrs, err := oper.mdb.ListFilesByCollection(ctx, param.Path)
if err != nil {
code := http.StatusInternalServerError
return code, res, err
}
// TODO: transaction
for _, file := range fileDescrs {
err = oper.store.DeleteFile(file.Collection, file.Name)
if err != nil {
oper.logg.Warningf("%v", err)
err = nil
}
err = oper.mdb.DeleteFileByCollectionName(ctx, file.Collection, file.Name)
if err != nil {
code := http.StatusInternalServerError
return code, res, err
}
res.Files = append(res.Files, file)
}
}
code := http.StatusOK
return code, res, err
+1 -1
View File
@@ -5,9 +5,9 @@ import (
"fmt"
"regexp"
"mstore/app/descr"
"mstore/pkg/auxtool"
"mstore/pkg/auxuuid"
"mstore/pkg/descr"
)
// CreateGrant
+1 -1
View File
@@ -18,8 +18,8 @@ import (
"net/http"
"strconv"
"mstore/app/descr"
"mstore/pkg/auxoci"
"mstore/pkg/descr"
)
type ManifestExistsParams struct {
+1 -1
View File
@@ -10,9 +10,9 @@
package operator
import (
"mstore/app/descr"
"mstore/pkg/auxtool"
"mstore/pkg/auxuuid"
"mstore/pkg/descr"
ocidigest "github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"