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{
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user