carrierwave 3.0.3 → 3.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e7d9ca1331d473162430928f5819d657e9c601b5663965a75f37c2eacb5bd344
4
- data.tar.gz: a78745cfdebaa9b1d3cf49cfc513ac248d83690a6f1bafd6384dab81acd3e150
3
+ metadata.gz: d0521a369826478de3de2fa97eecc3c3b4cde957eae650f01e9a84064c7a942f
4
+ data.tar.gz: e9691718fd62655b3990754a334fe7f7637c6e4e9186fb5084aa0da227058bf1
5
5
  SHA512:
6
- metadata.gz: 51207e993ab7aaed4e68d338c7fdbfeee7f1334d914a403890c9364ad3d5aeadbd94206cc3b5fbb07bec7d7372abd346239e979a4d6c6f3c5278e92b4a823c94
7
- data.tar.gz: fcc86123d64aabeb6de357cf81f632c3343b3951915d21f1b69e04c8bacb2e7e4c14c8efab9e4b0be33fac28efb228a0e7795615d19d913c33806eccb8adaedc
6
+ metadata.gz: ee8a2cbafe89e7f29b898940a2e9fbc391a015ea0a91fc04d00da62ea2ecd8b83721c4f0dc873551255117a59c9b61ac8b57902dc1fbec54f29817acff3f8746
7
+ data.tar.gz: 4bcd521bc40e84509b779312f5a6eab363bca8e9871c179fb6340044e46cf44397a58b4ba3133caaed71845b3a9630f74cd6da8356f835c2cc7ce17fa4e9be0c
@@ -33,9 +33,9 @@ module CarrierWave
33
33
 
34
34
  def original_filename
35
35
  filename = filename_from_header || filename_from_uri
36
- mime_type = Marcel::TYPES[content_type]
37
- unless File.extname(filename).present? || mime_type.blank?
38
- extension = mime_type[0].first
36
+ extensions = Marcel::Magic.new(content_type).extensions
37
+ unless File.extname(filename).present? || extensions.blank?
38
+ extension = extensions.first
39
39
  filename = "#{filename}.#{extension}"
40
40
  end
41
41
  filename
@@ -428,6 +428,11 @@ module CarrierWave
428
428
 
429
429
  private
430
430
 
431
+ def initialize_dup(other)
432
+ @_mounters = @_mounters.dup
433
+ super
434
+ end
435
+
431
436
  def _mounter(column)
432
437
  # We cannot memoize in frozen objects :(
433
438
  return Mounter.build(self, column) if frozen?
@@ -24,11 +24,16 @@ module CarrierWave
24
24
 
25
25
  after_save :"store_#{column}!"
26
26
  before_save :"write_#{column}_identifier"
27
+ if ::ActiveRecord.try(:run_after_transaction_callbacks_in_order_defined)
28
+ after_commit :"remove_previously_stored_#{column}", :on => :update
29
+ after_commit :"reset_previous_changes_for_#{column}"
30
+ after_commit :"mark_remove_#{column}_false", :on => :update
31
+ else
32
+ after_commit :"mark_remove_#{column}_false", :on => :update
33
+ after_commit :"reset_previous_changes_for_#{column}"
34
+ after_commit :"remove_previously_stored_#{column}", :on => :update
35
+ end
27
36
  after_commit :"remove_#{column}!", :on => :destroy
28
- after_commit :"mark_remove_#{column}_false", :on => :update
29
-
30
- after_commit :"reset_previous_changes_for_#{column}"
31
- after_commit :"remove_previously_stored_#{column}", :on => :update
32
37
  after_rollback :"remove_rolled_back_#{column}"
33
38
 
34
39
  mod = Module.new
@@ -43,10 +48,10 @@ module CarrierWave
43
48
  # Reset cached mounter on record dup
44
49
  def initialize_dup(other)
45
50
  old_uploaders = _mounter(:"#{column}").uploaders
46
- @_mounters[:"#{column}"] = nil
47
51
  super
52
+ @_mounters[:"#{column}"] = nil
48
53
  # The attribute needs to be cleared to prevent it from picked up as identifier
49
- write_attribute(:"#{column}", nil)
54
+ write_attribute(_mounter(:#{column}).serialization_column, nil)
50
55
  _mounter(:"#{column}").cache(old_uploaders)
51
56
  end
52
57
 
@@ -307,7 +307,7 @@ module CarrierWave
307
307
  def declared_content_type
308
308
  @declared_content_type ||
309
309
  if @file.respond_to?(:content_type) && @file.content_type
310
- @file.content_type.to_s.chomp
310
+ Marcel::MimeType.for(declared_type: @file.content_type.to_s.chomp)
311
311
  end
312
312
  end
313
313
 
@@ -53,7 +53,7 @@ module CarrierWave
53
53
  def allowlisted_content_type?(allowlist, content_type)
54
54
  Array(allowlist).any? do |item|
55
55
  item = Regexp.quote(item) if item.class != Regexp
56
- content_type =~ /#{item}/
56
+ content_type =~ /\A#{item}/
57
57
  end
58
58
  end
59
59
 
@@ -40,10 +40,10 @@ module CarrierWave
40
40
  #
41
41
  # === Returns
42
42
  #
43
- # [String] a temporary_identifier, by default @original_filename is used
43
+ # [String] a temporary_identifier, by default the value of #cache_name is used
44
44
  #
45
45
  def temporary_identifier
46
- @original_filename || @identifier
46
+ cache_name || @identifier
47
47
  end
48
48
 
49
49
  ##
@@ -87,7 +87,7 @@ module CarrierWave
87
87
  end
88
88
  @file = new_file
89
89
  @identifier = storage.identifier
90
- @cache_id = @deduplication_index = nil
90
+ @original_filename = @cache_id = @deduplication_index = nil
91
91
  @staged = false
92
92
  end
93
93
  end
@@ -279,7 +279,7 @@ module CarrierWave
279
279
  # that are the source of another version.
280
280
 
281
281
  self.cache_id = CarrierWave.generate_cache_id
282
- derived_versions.each do |name, v|
282
+ derived_versions.each_value do |v|
283
283
  v.cache!(file) if names.empty? || !(v.descendant_version_names & names).empty?
284
284
  end
285
285
  active_versions.each do |name, v|
@@ -308,13 +308,13 @@ module CarrierWave
308
308
  def derived_versions
309
309
  active_versions.reject do |name, v|
310
310
  v.class.version_options[:from_version]
311
- end.to_a + active_sibling_versions.select do |name, v|
311
+ end.merge(active_sibling_versions.select do |name, v|
312
312
  v.class.version_options[:from_version] == self.class.version_names.last
313
- end.to_a
313
+ end)
314
314
  end
315
315
 
316
316
  def active_sibling_versions
317
- parent_version&.active_versions || []
317
+ parent_version&.active_versions || {}
318
318
  end
319
319
 
320
320
  def full_filename(for_file)
@@ -326,23 +326,23 @@ module CarrierWave
326
326
  end
327
327
 
328
328
  def cache_versions!(new_file)
329
- derived_versions.each { |name, v| v.cache!(new_file) }
329
+ derived_versions.each_value { |v| v.cache!(new_file) }
330
330
  end
331
331
 
332
332
  def store_versions!(new_file)
333
- active_versions.each { |name, v| v.store!(new_file) }
333
+ active_versions.each_value { |v| v.store!(new_file) }
334
334
  end
335
335
 
336
336
  def remove_versions!
337
- versions.each { |name, v| v.remove! }
337
+ versions.each_value { |v| v.remove! }
338
338
  end
339
339
 
340
340
  def retrieve_versions_from_cache!(cache_name)
341
- active_versions.each { |name, v| v.retrieve_from_cache!(cache_name) }
341
+ active_versions.each_value { |v| v.retrieve_from_cache!(cache_name) }
342
342
  end
343
343
 
344
344
  def retrieve_versions_from_store!(identifier)
345
- active_versions.each { |name, v| v.retrieve_from_store!(identifier) }
345
+ active_versions.each_value { |v| v.retrieve_from_store!(identifier) }
346
346
  end
347
347
 
348
348
  end # Versions
@@ -1,3 +1,3 @@
1
1
  module CarrierWave
2
- VERSION = "3.0.3".freeze
2
+ VERSION = "3.0.7".freeze
3
3
  end
@@ -42,6 +42,6 @@ class <%= class_name %>Uploader < CarrierWave::Uploader::Base
42
42
  # Override the filename of the uploaded files:
43
43
  # Avoid using model.id or version_name here, see uploader/store.rb for details.
44
44
  # def filename
45
- # "something.jpg" if original_filename
45
+ # "something.jpg"
46
46
  # end
47
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Nicklas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-21 00:00:00.000000000 Z
11
+ date: 2024-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -95,19 +95,19 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: rails
98
+ name: csv
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 6.0.0
103
+ version: '3.0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 6.0.0
110
+ version: '3.0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: cucumber
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -400,7 +400,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
400
400
  - !ruby/object:Gem::Version
401
401
  version: '0'
402
402
  requirements: []
403
- rubygems_version: 3.3.7
403
+ rubygems_version: 3.4.10
404
404
  signing_key:
405
405
  specification_version: 4
406
406
  summary: Ruby file upload library