MM-60115, MM-62436, MM-62493: Compliance export downloads from local and s3; e2e tests (#29806)

* add ZipReader method to filestore and file/s3 backends

to merge

to merge

* add WriteStreamResponse as an alternative to WriteFileResponse

* add generated layers

* enable download link; download job endpoint now streams export dir zips

* fix MM-62493

* re-enable e2e tests--we have download links, folks

* Add tests for ZipReader in filestore and s3store

* remove unnecessary error return on ZipReader

* little cleanup

* improve tests; some refactoring: s.Nil(err) -> s.NoError(err)

* blank commit

* backwards compatability for pre-10.5 job downloads

* compress file response; better errors; better comments; PR comments

* update generated app layers

* improve/widen tests; improve comments; simplify localstore ZipReader

* regenerate layers

* follow GoDoc conventions

* update generated layers

* remove unnecessary comment

* in jobs/job-id/download, clean exportDir before sending to ZipReader

* better comments; add an error return on ZipReader

* improve file permissions

* adjust tests for new error returns

* linting

* i18n
Этот коммит содержится в:
Christopher Poile
2025-01-26 22:58:07 -05:00
коммит произвёл GitHub
родитель 396ee06dcb
Коммит 737bed311c
21 изменённых файлов: 753 добавлений и 110 удалений

Просмотреть файл

@@ -150,10 +150,14 @@ func CsvExport(rctx request.CTX, p shared.ExportParams) (shared.RunExportResults
for _, attachment := range attachments {
var r io.ReadCloser
r, nErr := p.FileAttachmentBackend.Reader(attachment.Path)
if nErr != nil {
missingFiles = append(missingFiles, "Warning:"+shared.MissingFileMessage+" - Post: "+*post.PostId+" - "+attachment.Path)
rctx.Logger().Warn(shared.MissingFileMessage, mlog.String("post_id", *post.PostId), mlog.String("filename", attachment.Path))
r, err = p.FileAttachmentBackend.Reader(attachment.Path)
if err != nil {
missingFiles = append(missingFiles, "Warning:"+shared.MissingFileMessageDuringBackendRead+" - Post: "+*post.PostId+" - "+attachment.Path)
rctx.Logger().Warn(shared.MissingFileMessageDuringBackendRead,
mlog.String("post_id", *post.PostId),
mlog.String("filename", attachment.Path),
mlog.Err(err),
)
continue
}
@@ -173,7 +177,16 @@ func CsvExport(rctx request.CTX, p shared.ExportParams) (shared.RunExportResults
return nil
}(); err != nil {
return results, fmt.Errorf("unable to copy the attachment into the zip file: %w", err)
// s3 only errors _here_ if the object key wasn't found. So to handle that: if there is a read
// error (even for local), let's add a warning instead of failing the export.
// Failing the export would fail the entire export run, and every future run would also fail on
// this non-existent file -- not good.
missingFiles = append(missingFiles, "Warning:"+shared.MissingFileMessageDuringCopy+" - Post: "+*post.PostId+" - "+attachment.Path)
rctx.Logger().Warn(shared.MissingFileMessageDuringCopy,
mlog.String("post_id", *post.PostId),
mlog.String("filename", attachment.Path),
mlog.Err(err),
)
}
}
}

Просмотреть файл

@@ -906,7 +906,7 @@ func TestWriteExportWarnings(t *testing.T) {
warnings := string(data)
expectedWarnings := fmt.Sprintf("Warning:%[1]s - Post: post-id-1 - test1\nWarning:%[1]s - Post: post-id-3 - test2\n",
shared.MissingFileMessage)
shared.MissingFileMessageDuringBackendRead)
assert.Equal(t, expectedWarnings, warnings)
}