Skip to content
Snippets Groups Projects
Commit 88d712e6 authored by Travis Ralston's avatar Travis Ralston
Browse files

Remove a case of a download causing a second download

parent 38e80e4b
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
* Fixed photo oEmbed URL previews (Giphy).
* Fixed orientation parsing for some thumbnails.
* Fixed file name being incorrect on the first download from remote servers.
* Fixed a download inefficiency where remote downloads could use extra bandwidth.
## [1.2.4] - March 5th, 2021
......
......@@ -134,7 +134,18 @@ func downloadResourceWorkFn(request *resource_handler.WorkRequest) interface{} {
persistFile := func(fileStream io.ReadCloser) *workerDownloadResponse {
defer cleanup.DumpAndCloseStream(fileStream)
userId := upload_controller.NoApplicableUploadUser
media, err := upload_controller.StoreDirect(nil, fileStream, downloaded.ContentLength, downloaded.ContentType, downloaded.DesiredFilename, userId, info.origin, info.mediaId, common.KindRemoteMedia, ctx, true)
ms := stream.NewMemStream()
io.Copy(ms, fileStream)
ms.Close()
st, err := ms.NextReader()
if err != nil {
ctx.Log.Error("Unexpected error persisting file: ", err)
return &workerDownloadResponse{err: err}
}
media, err := upload_controller.StoreDirect(nil, st, downloaded.ContentLength, downloaded.ContentType, downloaded.DesiredFilename, userId, info.origin, info.mediaId, common.KindRemoteMedia, ctx, true)
if err != nil {
ctx.Log.Error("Error persisting file: ", err)
return &workerDownloadResponse{err: err}
......@@ -145,6 +156,7 @@ func downloadResourceWorkFn(request *resource_handler.WorkRequest) interface{} {
media: media,
contentType: media.ContentType,
filename: media.UploadName,
stream: ms,
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment