[MM-57078] Adding progress logs for attachments to bulk export job (#26396)
* adding progress logs to export job --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
@@ -138,26 +138,33 @@ func (a *App) BulkExport(ctx request.CTX, writer io.Writer, outPath string, job
|
||||
|
||||
if opts.IncludeAttachments {
|
||||
ctx.Logger().Info("Bulk export: exporting file attachments")
|
||||
for _, attachment := range attachments {
|
||||
if err := a.exportFile(outPath, *attachment.Path, zipWr); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = a.exportAttachments(ctx, attachments, outPath, zipWr); err != nil {
|
||||
return err
|
||||
}
|
||||
for _, attachment := range directAttachments {
|
||||
if err := a.exportFile(outPath, *attachment.Path, zipWr); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ctx.Logger().Info("Bulk export: exporting direct file attachments")
|
||||
if err = a.exportAttachments(ctx, directAttachments, outPath, zipWr); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
totalExportedEmojis := 0
|
||||
emojisLen := len(emojiPaths)
|
||||
ctx.Logger().Info("Bulk export: exporting custom emojis")
|
||||
for _, emojiPath := range emojiPaths {
|
||||
if err := a.exportFile(outPath, emojiPath, zipWr); err != nil {
|
||||
return err
|
||||
}
|
||||
totalExportedEmojis++
|
||||
if totalExportedEmojis%10 == 0 {
|
||||
ctx.Logger().Info("Bulk export: exporting emojis progress", mlog.Int("total_successfully_exported_emojis", totalExportedEmojis), mlog.Int("total_emojis_to_export", emojisLen))
|
||||
}
|
||||
}
|
||||
|
||||
updateJobProgress(ctx.Logger(), a.Srv().Store(), job, "attachments_exported", len(attachments)+len(directAttachments)+len(emojiPaths))
|
||||
}
|
||||
|
||||
if opts.IncludeProfilePictures {
|
||||
ctx.Logger().Info("Bulk export: exporting profile pictures")
|
||||
for _, profilePicture := range profilePictures {
|
||||
if err := a.exportFile(outPath, profilePicture, zipWr); err != nil {
|
||||
ctx.Logger().Warn("Unable to export profile picture", mlog.String("profile_picture", profilePicture), mlog.Err(err))
|
||||
@@ -169,6 +176,21 @@ func (a *App) BulkExport(ctx request.CTX, writer io.Writer, outPath string, job
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) exportAttachments(ctx request.CTX, attachments []imports.AttachmentImportData, outPath string, zipWr *zip.Writer) *model.AppError {
|
||||
totalExportedFiles := 0
|
||||
attachmentsLen := len(attachments)
|
||||
for _, attachment := range attachments {
|
||||
if err := a.exportFile(outPath, *attachment.Path, zipWr); err != nil {
|
||||
return err
|
||||
}
|
||||
totalExportedFiles++
|
||||
if totalExportedFiles%10 == 0 {
|
||||
ctx.Logger().Info("Bulk export: exporting file attachments progress", mlog.Int("total_successfully_exported_files", totalExportedFiles), mlog.Int("total_files_to_export", attachmentsLen))
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) exportWriteLine(w io.Writer, line *imports.LineImportData) *model.AppError {
|
||||
b, err := json.Marshal(line)
|
||||
if err != nil {
|
||||
|
||||
Ссылка в новой задаче
Block a user