working commit
This commit is contained in:
+46
-17
@@ -299,12 +299,6 @@ func (oper *Operator) ListFiles(ctx context.Context, operID string, params *List
|
|||||||
res := &ListFilesResult{
|
res := &ListFilesResult{
|
||||||
Files: make([]descr.File, 0),
|
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 {
|
switch params.PathAs {
|
||||||
case terms.AsRegexp:
|
case terms.AsRegexp:
|
||||||
files, err := oper.listFilesWithRegex(ctx, params.Filepath)
|
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
|
res.Files = files
|
||||||
case terms.AsPrefix:
|
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)
|
files, err := oper.listFilesWithPrefix(ctx, params.Filepath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
code := http.StatusInternalServerError
|
code := http.StatusInternalServerError
|
||||||
@@ -321,6 +326,17 @@ func (oper *Operator) ListFiles(ctx context.Context, operID string, params *List
|
|||||||
}
|
}
|
||||||
res.Files = files
|
res.Files = files
|
||||||
default: // Fine
|
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)
|
files, err := oper.listFilesInOneCollection(ctx, params.Filepath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
code := http.StatusInternalServerError
|
code := http.StatusInternalServerError
|
||||||
@@ -395,11 +411,7 @@ func (oper *Operator) ListCollections(ctx context.Context, operID string, param
|
|||||||
res := &ListCollectionsResult{
|
res := &ListCollectionsResult{
|
||||||
Collections: make([]string, 0),
|
Collections: make([]string, 0),
|
||||||
}
|
}
|
||||||
param.Path, err = cleanFilepath(param.Path)
|
|
||||||
if err != nil {
|
|
||||||
code := http.StatusInternalServerError
|
|
||||||
return code, res, err
|
|
||||||
}
|
|
||||||
collectionList := make([]string, 0)
|
collectionList := make([]string, 0)
|
||||||
switch param.PathAS {
|
switch param.PathAS {
|
||||||
case terms.AsRegexp:
|
case terms.AsRegexp:
|
||||||
@@ -409,12 +421,24 @@ func (oper *Operator) ListCollections(ctx context.Context, operID string, param
|
|||||||
return code, res, err
|
return code, res, err
|
||||||
}
|
}
|
||||||
case terms.AsPrefix:
|
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)
|
collectionList, err = oper.listCollectionsWithPrefix(ctx, param.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
code := http.StatusInternalServerError
|
code := http.StatusInternalServerError
|
||||||
return code, res, err
|
return code, res, err
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
param.Path, err = cleanFilepath(param.Path)
|
||||||
|
if err != nil {
|
||||||
|
code := http.StatusInternalServerError
|
||||||
|
return code, res, err
|
||||||
|
}
|
||||||
|
|
||||||
collectionList, err = oper.listAllCollections(ctx)
|
collectionList, err = oper.listAllCollections(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
code := http.StatusInternalServerError
|
code := http.StatusInternalServerError
|
||||||
@@ -520,12 +544,6 @@ func (oper *Operator) DeleteColletion(ctx context.Context, operID string, param
|
|||||||
res := &DeleteColletionResult{
|
res := &DeleteColletionResult{
|
||||||
Files: make([]descr.File, 0),
|
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 {
|
switch param.PathAs {
|
||||||
case terms.AsRegexp:
|
case terms.AsRegexp:
|
||||||
collections, err := oper.listCollectionsWithRegexp(ctx, param.Path)
|
collections, err := oper.listCollectionsWithRegexp(ctx, param.Path)
|
||||||
@@ -545,6 +563,12 @@ func (oper *Operator) DeleteColletion(ctx context.Context, operID string, param
|
|||||||
res.Files = allfiles
|
res.Files = allfiles
|
||||||
|
|
||||||
case terms.AsPrefix:
|
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)
|
collections, err := oper.listCollectionsWithPrefix(ctx, param.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
code := http.StatusInternalServerError
|
code := http.StatusInternalServerError
|
||||||
@@ -561,6 +585,11 @@ func (oper *Operator) DeleteColletion(ctx context.Context, operID string, param
|
|||||||
}
|
}
|
||||||
res.Files = allfiles
|
res.Files = allfiles
|
||||||
default: // Fine
|
default: // Fine
|
||||||
|
param.Path, err = cleanFilepath(param.Path)
|
||||||
|
if err != nil {
|
||||||
|
code := http.StatusInternalServerError
|
||||||
|
return code, res, err
|
||||||
|
}
|
||||||
collection := param.Path
|
collection := param.Path
|
||||||
files, err := oper.deleteFilesInCollection(ctx, collection, param.DryRun)
|
files, err := oper.deleteFilesInCollection(ctx, collection, param.DryRun)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
+1
-1
@@ -65,7 +65,7 @@ func pathCompiler(path string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
defaultRegexp = `[a-zA-Z0-9_\.][/\-\.,a-zA-Z0-9_%=*\[\]:~]+`
|
defaultRegexp = `[a-zA-Z0-9_\.*][/\-\.,a-zA-Z0-9_%=*\[\]:~\$]+`
|
||||||
)
|
)
|
||||||
|
|
||||||
func convertRegexp(src []byte) []byte {
|
func convertRegexp(src []byte) []byte {
|
||||||
|
|||||||
Reference in New Issue
Block a user