Skip to content
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

lately resolve active versions when retrieving #2669

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rajyan
Copy link
Contributor

@rajyan rajyan commented Jul 4, 2023

I believe this fixes #2461 #2148

#2132

Minimum reproducible example and details are in
#2461 (comment)

@rajyan
Copy link
Contributor Author

rajyan commented Jul 5, 2023

I noticed that this PR might also fix #2148 without breaking the purpose of #1351
I would add tests for them if necessary.

Also, #2132 was exactly what I'm trying to solve.

Comment on lines 327 to 334
def retrieve_versions_from_cache!(cache_name)
active_versions.each { |name, v| v.retrieve_from_cache!(cache_name) }
versions.each { |name, v| v.retrieve_from_cache!(cache_name) }
end

def retrieve_versions_from_store!(identifier)
active_versions.each { |name, v| v.retrieve_from_store!(identifier) }
versions.each { |name, v| v.retrieve_from_store!(identifier) }
end

Copy link
Contributor Author

@rajyan rajyan Jul 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to evaluate the condition here, like before the changes in #1351 .
We can keep all versions retrieved internally, evaluate the condition and return them only when users accesses.

@@ -133,7 +133,7 @@ def version(name, options = {}, &block)

class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{name}
versions[:#{name}]
version_exists?(:#{name}) ? versions[:#{name}] : versions[:#{name}].class.new(model, mounted_as)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lately resolving the condition here. Which would make it more consistent with the current state (active or not) of the version (which fixes #2148 too).

I think it is better to return nil for non-active versions, but returning a blank uploader for backwards compatibility.

@rajyan
Copy link
Contributor Author

rajyan commented Jul 14, 2023

@mshibuya

I added some comments to make the change clearer. Hope this makes sense 😄

@rajyan
Copy link
Contributor Author

rajyan commented Jul 15, 2023

Looking at #2132
carefully, this PR didn’t solve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Long time delay associated with head requests to Amazon S3
1 participant