diff --git a/server/channels/api4/job.go b/server/channels/api4/job.go index ca9776c3ea..815e063f3b 100644 --- a/server/channels/api4/job.go +++ b/server/channels/api4/job.go @@ -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) diff --git a/server/channels/app/file.go b/server/channels/app/file.go index 049c0437fa..25f56e3ba1 100644 --- a/server/channels/app/file.go +++ b/server/channels/app/file.go @@ -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) }