MM-29525: Strip path_prefix from ListDirectory (#15949)
* MM-29525: Strip path_prefix from ListDirectory An AWS path prefix is meant to be an implementation detail which the calling application should not be aware of. Hence, we should strip the path prefix when returning objects in a directory because they anyways get applied while using the other APIs https://mattermost.atlassian.net/browse/MM-29525 * simplify Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
79b5350576
Коммит
d2730014f9
@@ -350,7 +350,13 @@ func (b *S3FileBackend) ListDirectory(path string) (*[]string, *model.AppError)
|
||||
if object.Err != nil {
|
||||
return nil, model.NewAppError("ListDirectory", "utils.file.list_directory.s3.app_error", nil, object.Err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
paths = append(paths, strings.Trim(object.Key, "/"))
|
||||
// We strip the path prefix that gets applied,
|
||||
// so that it remains transparent to the application.
|
||||
object.Key = strings.TrimPrefix(object.Key, b.pathPrefix)
|
||||
trimmed := strings.Trim(object.Key, "/")
|
||||
if trimmed != "" {
|
||||
paths = append(paths, trimmed)
|
||||
}
|
||||
}
|
||||
|
||||
return &paths, nil
|
||||
|
||||
Ссылка в новой задаче
Block a user