Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

AO3-5188 (BOT) Make downloads synchronous #3090

Merged
merged 4 commits into from Oct 2, 2017

Conversation

Projects
None yet
3 participants
Contributor

zz9pzza commented Oct 2, 2017

Issue

https://otwarchive.atlassian.net/browse/AO3-*5188

Testing

Check the downloads work...

app/controllers/downloads_controller.rb
@@ -92,7 +95,10 @@ def download_mobi
flash[:error] = ts('We were not able to render this work. Please try another format')
redirect_back_or_default work_path(@work) and return
end
- send_file("#{@work.download_basename}.mobi", type: "application/x-mobipocket-ebook")
+ # send file synchronously so we don't delete it before we have finsihed sending it.
+ File.open("#{@work.download_basename}.mobi", 'r') do |f|
@houndci-bot

houndci-bot Oct 2, 2017

Inconsistent indentation detected.

@ariana-paris ariana-paris changed the title from AO3-5188 (BOT) Make things synchronous to AO3-5188 (BOT) Make downloads synchronous Oct 2, 2017

app/controllers/downloads_controller.rb
@@ -92,7 +99,7 @@ def download_mobi
flash[:error] = ts('We were not able to render this work. Please try another format')
redirect_back_or_default work_path(@work) and return
end
- send_file("#{@work.download_basename}.mobi", type: "application/x-mobipocket-ebook")
+ send_file_sync("#{@work.download_basename}.mobi", "#{@work.download_title}.mobi", "application/x-mobipocket-ebook")
@houndci-bot

houndci-bot Oct 2, 2017

Inconsistent indentation detected.

- title = Shellwords.escape(@work.title)
- author = Shellwords.escape(@work.display_authors)
- cmd_post = %Q{ --mobifile "#{@work.download_title}.mobi" --title #{title} --author #{author} }
+ cmd_pre = %Q{cd "#{@work.download_dir}"; html2mobi }
@houndci-bot

houndci-bot Oct 2, 2017

Use % instead of %Q.

+ # metadata needs to be escaped for command line
+ title = Shellwords.escape(@work.title)
+ author = Shellwords.escape(@work.display_authors)
+ cmd_post = %Q{ --mobifile "#{@work.download_title}.mobi" --title #{title} --author #{author} }
@houndci-bot

houndci-bot Oct 2, 2017

Use % instead of %Q.

@elzj elzj merged commit 3a2d8de into otwcode:master Oct 2, 2017

4 checks passed

Scrutinizer 3 new issues, 1 updated code elements
Details
codeclimate 1 fixed issue
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
hound 2 violations found.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment