Skip to content

Commit

Permalink
fix cache/ storage coordination bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Corin Langosch committed May 12, 2011
1 parent 9af401e commit aaf6909
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/carrierwave/uploader/versions.rb
Expand Up @@ -146,6 +146,13 @@ def recreate_versions!

private

def set_active_versions!(new_file)
@active_versions = versions.reject do |name, uploader|
condition = self.class.versions[name][:options][:if]
condition && !send(condition, new_file)
end
end

def full_filename(for_file)
[version_name, super(for_file)].compact.join('_')
end
Expand All @@ -155,24 +162,22 @@ def full_original_filename
end

def cache_versions!(new_file)
set_active_versions!(new_file)

# We might have processed the new_file argument after the callbacks were
# initialized, so get the actual file based off of the current state of
# our file
processed_parent = SanitizedFile.new :tempfile => self.file,
:filename => new_file.original_filename

versions.each do |name, v|
@active_versions.each do |name, v|
v.send(:cache_id=, cache_id)
v.cache!(processed_parent)
end
end

def store_versions!(new_file)
filtered_versions = versions.reject do |name, uploader|
condition = self.class.versions[name][:options][:if]
condition && !send(condition, new_file)
end
filtered_versions.each { |name, v| v.store!(new_file) }
@active_versions.each { |name, v| v.store!(new_file) }

This comment has been minimized.

Copy link
@filipegiusti

filipegiusti Mar 21, 2014

Contributor

If the store! only happens in the @active_versions shouldn't the retrieve_versions_from_store! and retrieve_versions_from_cache! also use @active_versions instead of versions?

This seems to cause a bug when I use default_url in a version that has an :if.

end

def remove_versions!
Expand Down

0 comments on commit aaf6909

Please sign in to comment.