mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
[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:
parent
3a73b517e2
commit
6560b4c0cf
@ -100,7 +100,7 @@ func downloadJob(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
fileName = job.Id + ".zip"
|
fileName = job.Id + ".zip"
|
||||||
filePath := filepath.Join(oldFilePath, fileName)
|
filePath := filepath.Join(oldFilePath, fileName)
|
||||||
var fileReader filestore.ReadCloseSeeker
|
var fileReader filestore.ReadCloseSeeker
|
||||||
fileReader, err = c.App.FileReader(filePath)
|
fileReader, err = c.App.ExportFileReader(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Err = model.NewAppError("unableToDownloadJob", "api.job.unable_to_download_job", 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",
|
"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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
zipReader, err := c.App.ZipReader(cleanedExportDir, false)
|
zipReader, err := c.App.ExportZipReader(cleanedExportDir, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Err = model.NewAppError("unableToDownloadJob", "api.job.unable_to_download_job", nil,
|
c.Err = model.NewAppError("unableToDownloadJob", "api.job.unable_to_download_job", nil,
|
||||||
"error creating zip reader", http.StatusNotFound).Wrap(err)
|
"error creating zip reader", http.StatusNotFound).Wrap(err)
|
||||||
|
@ -144,6 +144,10 @@ func (s *Server) exportFileReader(path string) (filestore.ReadCloseSeeker, *mode
|
|||||||
return fileReader(s.ExportFileBackend(), path)
|
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.
|
// FileReader returns a ReadCloseSeeker for path from the FileBackend.
|
||||||
//
|
//
|
||||||
// The caller is responsible for closing the returned ReadCloseSeeker.
|
// 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)
|
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) {
|
func (a *App) FileExists(path string) (bool, *model.AppError) {
|
||||||
return a.Srv().fileExists(path)
|
return a.Srv().fileExists(path)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user