[MM-55595] Use annotated logger in search layer (#25468)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
5a4dba8809
Коммит
b2ec1ff8ae
@@ -505,7 +505,7 @@ func (a *App) MigrateFilenamesToFileInfos(rctx request.CTX, post *model.Post) []
|
||||
savedInfos := make([]*model.FileInfo, 0, len(infos))
|
||||
fileIDs := make([]string, 0, len(filenames))
|
||||
for _, info := range infos {
|
||||
if _, nErr = a.Srv().Store().FileInfo().Save(info); nErr != nil {
|
||||
if _, nErr = a.Srv().Store().FileInfo().Save(rctx, info); nErr != nil {
|
||||
rctx.Logger().Error(
|
||||
"Unable to save file info when migrating post to use FileInfos",
|
||||
mlog.String("post_id", post.Id),
|
||||
@@ -527,7 +527,7 @@ func (a *App) MigrateFilenamesToFileInfos(rctx request.CTX, post *model.Post) []
|
||||
newPost.FileIds = fileIDs
|
||||
|
||||
// Update Posts to clear Filenames and set FileIds
|
||||
if _, nErr = a.Srv().Store().Post().Update(newPost, post); nErr != nil {
|
||||
if _, nErr = a.Srv().Store().Post().Update(rctx, newPost, post); nErr != nil {
|
||||
rctx.Logger().Error(
|
||||
"Unable to save migrated post when migrating to use FileInfos",
|
||||
mlog.String("new_file_ids", strings.Join(newPost.FileIds, ",")),
|
||||
@@ -678,7 +678,7 @@ type UploadFileTask struct {
|
||||
// Testing: overridable dependency functions
|
||||
pluginsEnvironment *plugin.Environment
|
||||
writeFile func(io.Reader, string) (int64, *model.AppError)
|
||||
saveToDatabase func(*model.FileInfo) (*model.FileInfo, error)
|
||||
saveToDatabase func(request.CTX, *model.FileInfo) (*model.FileInfo, error)
|
||||
|
||||
imgDecoder *imaging.Decoder
|
||||
imgEncoder *imaging.Encoder
|
||||
@@ -722,7 +722,7 @@ func (t *UploadFileTask) init(a *App) {
|
||||
// contained the last "good" FileInfo before the execution of that plugin.
|
||||
func (a *App) UploadFileX(c request.CTX, channelID, name string, input io.Reader,
|
||||
opts ...func(*UploadFileTask)) (*model.FileInfo, *model.AppError) {
|
||||
c.WithLogger(c.Logger().With(
|
||||
c = c.WithLogger(c.Logger().With(
|
||||
mlog.String("file_name", name),
|
||||
))
|
||||
|
||||
@@ -791,7 +791,7 @@ func (a *App) UploadFileX(c request.CTX, channelID, name string, input io.Reader
|
||||
t.postprocessImage(file)
|
||||
}
|
||||
|
||||
if _, err := t.saveToDatabase(t.fileinfo); err != nil {
|
||||
if _, err := t.saveToDatabase(c, t.fileinfo); err != nil {
|
||||
var appErr *model.AppError
|
||||
switch {
|
||||
case errors.As(err, &appErr):
|
||||
@@ -1042,7 +1042,7 @@ func (a *App) DoUploadFileExpectModification(c request.CTX, now time.Time, rawTe
|
||||
return nil, data, err
|
||||
}
|
||||
|
||||
if _, err := a.Srv().Store().FileInfo().Save(info); err != nil {
|
||||
if _, err := a.Srv().Store().FileInfo().Save(c, info); err != nil {
|
||||
var appErr *model.AppError
|
||||
switch {
|
||||
case errors.As(err, &appErr):
|
||||
@@ -1177,7 +1177,7 @@ func (a *App) generateMiniPreview(rctx request.CTX, fi *model.FileInfo) {
|
||||
} else {
|
||||
fi.MiniPreview = &miniPreview
|
||||
}
|
||||
if _, err = a.Srv().Store().FileInfo().Upsert(fi); err != nil {
|
||||
if _, err = a.Srv().Store().FileInfo().Upsert(rctx, fi); err != nil {
|
||||
rctx.Logger().Debug("Creating mini preview failed", mlog.Err(err))
|
||||
} else {
|
||||
a.Srv().Store().FileInfo().InvalidateFileInfosForPostCache(fi.PostId, false)
|
||||
@@ -1230,13 +1230,13 @@ func (a *App) GetFileInfo(rctx request.CTX, fileID string) (*model.FileInfo, *mo
|
||||
return fileInfo, appErr
|
||||
}
|
||||
|
||||
func (a *App) SetFileSearchableContent(fileID string, data string) *model.AppError {
|
||||
func (a *App) SetFileSearchableContent(rctx request.CTX, fileID string, data string) *model.AppError {
|
||||
fileInfo, appErr := a.Srv().getFileInfo(fileID)
|
||||
if appErr != nil {
|
||||
return appErr
|
||||
}
|
||||
|
||||
err := a.Srv().Store().FileInfo().SetContent(fileInfo.Id, data)
|
||||
err := a.Srv().Store().FileInfo().SetContent(rctx, fileInfo.Id, data)
|
||||
if err != nil {
|
||||
var nfErr *store.ErrNotFound
|
||||
switch {
|
||||
@@ -1317,7 +1317,7 @@ func (a *App) getFileIgnoreCloudLimit(rctx request.CTX, fileID string) ([]byte,
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (a *App) CopyFileInfos(userID string, fileIDs []string) ([]string, *model.AppError) {
|
||||
func (a *App) CopyFileInfos(rctx request.CTX, userID string, fileIDs []string) ([]string, *model.AppError) {
|
||||
var newFileIds []string
|
||||
|
||||
now := model.GetMillis()
|
||||
@@ -1341,7 +1341,7 @@ func (a *App) CopyFileInfos(userID string, fileIDs []string) ([]string, *model.A
|
||||
fileInfo.PostId = ""
|
||||
fileInfo.ChannelId = ""
|
||||
|
||||
if _, err := a.Srv().Store().FileInfo().Save(fileInfo); err != nil {
|
||||
if _, err := a.Srv().Store().FileInfo().Save(rctx, fileInfo); err != nil {
|
||||
var appErr *model.AppError
|
||||
switch {
|
||||
case errors.As(err, &appErr):
|
||||
@@ -1428,8 +1428,8 @@ func (a *App) SearchFilesInTeamForUser(c request.CTX, terms string, userId strin
|
||||
params.ExcludedChannels = a.convertChannelNamesToChannelIds(c, params.ExcludedChannels, userId, teamId, includeDeletedChannels)
|
||||
|
||||
// Convert usernames to user IDs
|
||||
params.FromUsers = a.convertUserNameToUserIds(params.FromUsers)
|
||||
params.ExcludedUsers = a.convertUserNameToUserIds(params.ExcludedUsers)
|
||||
params.FromUsers = a.convertUserNameToUserIds(c, params.FromUsers)
|
||||
params.ExcludedUsers = a.convertUserNameToUserIds(c, params.ExcludedUsers)
|
||||
|
||||
finalParamsList = append(finalParamsList, params)
|
||||
}
|
||||
@@ -1440,7 +1440,7 @@ func (a *App) SearchFilesInTeamForUser(c request.CTX, terms string, userId strin
|
||||
return model.NewFileInfoList(), nil
|
||||
}
|
||||
|
||||
fileInfoSearchResults, nErr := a.Srv().Store().FileInfo().Search(finalParamsList, userId, teamId, page, perPage)
|
||||
fileInfoSearchResults, nErr := a.Srv().Store().FileInfo().Search(c, finalParamsList, userId, teamId, page, perPage)
|
||||
if nErr != nil {
|
||||
var appErr *model.AppError
|
||||
switch {
|
||||
@@ -1475,7 +1475,7 @@ func (a *App) ExtractContentFromFileInfo(rctx request.CTX, fileInfo *model.FileI
|
||||
if len(text) > maxContentExtractionSize {
|
||||
text = text[0:maxContentExtractionSize]
|
||||
}
|
||||
if storeErr := a.Srv().Store().FileInfo().SetContent(fileInfo.Id, text); storeErr != nil {
|
||||
if storeErr := a.Srv().Store().FileInfo().SetContent(rctx, fileInfo.Id, text); storeErr != nil {
|
||||
return errors.Wrap(storeErr, "failed to save the extracted file content")
|
||||
}
|
||||
reloadFileInfo, storeErr := a.Srv().Store().FileInfo().Get(fileInfo.Id)
|
||||
|
||||
Ссылка в новой задаче
Block a user