[MM-62845] Fix: Compliance export download link fails from S3 when using a dedicated file store (#30092)

* add ExportZipReader and use that for job exports

* fix legacy code to use ExportFileReader
This commit is contained in:
Christopher Poile 2025-02-05 07:31:07 -05:00 committed by GitHub
parent 3a73b517e2
commit 6560b4c0cf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View File

@ -100,7 +100,7 @@ func downloadJob(c *Context, w http.ResponseWriter, r *http.Request) {
fileName = job.Id + ".zip"
filePath := filepath.Join(oldFilePath, fileName)
var fileReader filestore.ReadCloseSeeker
fileReader, err = c.App.FileReader(filePath)
fileReader, err = c.App.ExportFileReader(filePath)
if err != nil {
c.Err = model.NewAppError("unableToDownloadJob", "api.job.unable_to_download_job", nil,
"job.Data did not include export_dir, export_dir was malformed, or jobId.zip wasn't found",
@ -126,7 +126,7 @@ func downloadJob(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
zipReader, err := c.App.ZipReader(cleanedExportDir, false)
zipReader, err := c.App.ExportZipReader(cleanedExportDir, false)
if err != nil {
c.Err = model.NewAppError("unableToDownloadJob", "api.job.unable_to_download_job", nil,
"error creating zip reader", http.StatusNotFound).Wrap(err)

View File

@ -144,6 +144,10 @@ func (s *Server) exportFileReader(path string) (filestore.ReadCloseSeeker, *mode
return fileReader(s.ExportFileBackend(), path)
}
func (s *Server) exportZipReader(path string, deflate bool) (io.ReadCloser, *model.AppError) {
return zipReader(s.ExportFileBackend(), path, deflate)
}
// FileReader returns a ReadCloseSeeker for path from the FileBackend.
//
// The caller is responsible for closing the returned ReadCloseSeeker.
@ -165,6 +169,14 @@ func (a *App) ExportFileReader(path string) (filestore.ReadCloseSeeker, *model.A
return a.Srv().exportFileReader(path)
}
// ExportZipReader returns a ReadCloser for path from the ExportFileBackend.
// If deflate is true, the zip will use compression.
//
// The caller is responsible for closing the returned ReadCloser.
func (a *App) ExportZipReader(path string, deflate bool) (io.ReadCloser, *model.AppError) {
return a.Srv().exportZipReader(path, deflate)
}
func (a *App) FileExists(path string) (bool, *model.AppError) {
return a.Srv().fileExists(path)
}