New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AO3-5631 Make /tmp download directory unique per generation #3532
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -846,11 +846,6 @@ def set_word_count(preview = false) | |
end | ||
end | ||
|
||
after_update :remove_outdated_downloads | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this mean that more files will be left around ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, because we delete them after we generate and send them off. |
||
def remove_outdated_downloads | ||
Download.remove(self) | ||
end | ||
|
||
####################################################################### | ||
# TAGGING | ||
# Works are taggable objects. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,26 @@ | ||
Then /^I should receive a file of type "([^"]*)"$/ do |filetype| | ||
Then /^I should receive a file of type "(.*?)"$/ do |filetype| | ||
redsummernight marked this conversation as resolved.
Show resolved
Hide resolved
|
||
mime_type = filetype == "azw3" ? "application/x-mobi8-ebook" : MIME::Types.type_for("foo.#{filetype}").first | ||
page.driver.response.headers['Content-Disposition'].should =~ /filename=.+\.#{filetype}/ | ||
page.response_headers['Content-Type'].should == mime_type | ||
end | ||
|
||
Then /^I should be able to download all versions of "(.*)"$/ do |title| | ||
Then /^I should be able to download all versions of "(.*?)"$/ do |title| | ||
(ArchiveConfig.DOWNLOAD_FORMATS - ['html']).each do |filetype| | ||
step %{I should be able to download the #{filetype} version of "#{title}"} | ||
end | ||
end | ||
|
||
Then /^I (?:should be able to )?download the (\w+) version of "(.*)"$/ do |filetype, title| | ||
Then /^I should be able to download the (\w+) version of "(.*?)"$/ do |filetype, title| | ||
step %{time is frozen at this second} | ||
work = Work.find_by_title(title) | ||
download = Download.new(work, format: filetype) | ||
visit work_url(work) | ||
step %{I follow "#{filetype.upcase}"} | ||
step %{I jump in our Delorean and return to the present} | ||
|
||
filename = download.file_path # the full path of the download file we expect to exist | ||
mime_type = filetype == "azw3" ? "application/x-mobi8-ebook" : MIME::Types.type_for(filename).first | ||
assert File.exist?(filename), "#{filename} does not exist" | ||
page.driver.response.headers['Content-Disposition'].should =~ /filename=\"#{File.basename(filename)}\"/ | ||
page.response_headers['Content-Type'].should == mime_type | ||
end | ||
|
||
Then /^I should not be able to download the (\w+) version of "(.*)"$/ do |filetype, title| | ||
work = Work.find_by_title(title) | ||
download = Download.new(work, format: filetype) | ||
visit work_url(work) | ||
step %{I follow "#{filetype.upcase}"} | ||
filename = download.file_path # the full path of the download file we expect to exist | ||
mime_type = filetype == "azw3" ? "application/x-mobi8-ebook" : MIME::Types.type_for(filename).first | ||
page.driver.response.headers['Content-Disposition'].should_not =~ /filename=\"#{File.basename(filename)}\"/ | ||
page.response_headers['Content-Type'].should_not == mime_type | ||
end | ||
|
||
Then /^I should not be able to manually download the (\w+) version of "(.*)"$/ do |filetype, title| | ||
work = Work.find_by_title(title) | ||
download = Download.new(work, format: filetype) | ||
download_url = "#{ArchiveConfig.APP_URL}#{download.public_path}" | ||
filename = download.file_path # the full path of the download file we expect to exist | ||
mime_type = filetype == "azw3" ? "application/x-mobi8-ebook" : MIME::Types.type_for(filename).first | ||
visit download_url | ||
page.driver.response.headers['Content-Disposition'].should_not =~ /filename=\"#{File.basename(filename)}\"/ | ||
page.response_headers['Content-Type'].should_not == mime_type | ||
end | ||
|
||
Then /^the (.*) version of "([^"]*)" should exist$/ do |filetype, title| | ||
work = Work.find_by_title(title) | ||
filename = "#{work.download_basename}.#{filetype}" # the full path of the download file we expect to exist | ||
assert Download.new(work, format: filetype).exists?, "#{filename} does not exist" | ||
end | ||
|
||
Then /^the (.*) version of "([^"]*)" should not exist$/ do |filetype, title| | ||
work = Work.find_by_title(title) | ||
assert !Download.new(work, format: filetype).exists?, "#{filename} does exist" | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this unique enough or should I go for fractions of seconds as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're concerned about timing issues, what about using
Dir.mktmpdir
? It uses random numbers and checks forEEXIST
onmkdir
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks! I'll use that. I need to rewrite the tests to not rely on file location checks since we won't know the directory name.