carrierwave 3.0.0 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of carrierwave might be problematic. Click here for more details.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f12b8894846b8a7fdfecb1c537020481e3bb9c6c61d8169341b9cc8c2136f56
|
4
|
+
data.tar.gz: 2ca2f58d5fbedacf2f355e84e3fe57980b51fa6c17dc0fde2cbd87a40460a7d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee31d0127aa61484b2e9ddb8d9bd64e684d9a553e571487408f5a239837d3be369dfb64a81784239f76ea4355113a0f1b6098ddf28689eb5555b222e59596f2f
|
7
|
+
data.tar.gz: 75ec8c867a5048a988b63b7b3cc78d2d0da943b48605c7f96ec48d0a04f113a022eb7c138230bff079a7d478140d1738b58c2f65f32a0ce132631877006c0ec9
|
data/lib/carrierwave/mounter.rb
CHANGED
@@ -139,20 +139,22 @@ module CarrierWave
|
|
139
139
|
end
|
140
140
|
|
141
141
|
def store!
|
142
|
-
|
143
|
-
|
144
|
-
additions.each do |uploader|
|
145
|
-
uploader.deduplicate(existing_paths)
|
146
|
-
uploader.store!
|
147
|
-
existing_paths << uploader.store_path
|
148
|
-
end
|
149
|
-
@added_uploaders += additions
|
142
|
+
uploaders.each(&:store!)
|
143
|
+
@added_uploaders += uploaders.reject(&:staged)
|
150
144
|
end
|
151
145
|
|
152
146
|
def write_identifier
|
153
147
|
return if record.frozen?
|
154
148
|
|
155
149
|
clear! if remove?
|
150
|
+
|
151
|
+
additions, remains = uploaders.partition(&:cached?)
|
152
|
+
existing_identifiers = (@removed_uploaders + remains).map(&:identifier)
|
153
|
+
additions.each do |uploader|
|
154
|
+
uploader.deduplicate(existing_identifiers)
|
155
|
+
existing_identifiers << uploader.identifier
|
156
|
+
end
|
157
|
+
|
156
158
|
record.write_uploader(serialization_column, identifier)
|
157
159
|
end
|
158
160
|
|
@@ -202,7 +204,7 @@ module CarrierWave
|
|
202
204
|
end
|
203
205
|
|
204
206
|
def remove_added
|
205
|
-
current_paths = (@removed_uploaders +
|
207
|
+
current_paths = (@removed_uploaders + uploaders.select(&:staged)).map(&:path)
|
206
208
|
@added_uploaders
|
207
209
|
.reject {|uploader| current_paths.include?(uploader.path) }
|
208
210
|
.each { |uploader| uploader.remove! }
|
@@ -44,6 +44,8 @@ module CarrierWave
|
|
44
44
|
def initialize_dup(other)
|
45
45
|
old_uploaders = _mounter(:"#{column}").uploaders
|
46
46
|
@_mounters[:"#{column}"] = nil
|
47
|
+
# The attribute needs to be cleared to prevent it from picked up as identifier
|
48
|
+
write_attribute(:"#{column}", nil)
|
47
49
|
super
|
48
50
|
_mounter(:"#{column}").cache(old_uploaders)
|
49
51
|
end
|
@@ -43,11 +43,12 @@ module CarrierWave
|
|
43
43
|
#
|
44
44
|
def deduplicated_filename
|
45
45
|
return unless filename
|
46
|
+
return filename unless @deduplication_index
|
46
47
|
|
47
48
|
parts = filename.split('.')
|
48
49
|
basename = parts.shift
|
49
50
|
basename.sub!(/ ?\(\d+\)\z/, '')
|
50
|
-
([basename.to_s + (@deduplication_index ? "(#{@deduplication_index})" : '')] + parts).join('.')
|
51
|
+
([basename.to_s + (@deduplication_index > 1 ? "(#{@deduplication_index})" : '')] + parts).join('.')
|
51
52
|
end
|
52
53
|
|
53
54
|
##
|
@@ -107,22 +108,22 @@ module CarrierWave
|
|
107
108
|
end
|
108
109
|
|
109
110
|
##
|
110
|
-
# Look for
|
111
|
+
# Look for an identifier which doesn't collide with the given already-stored identifiers.
|
111
112
|
# It is done by adding a index number as the suffix.
|
112
113
|
# For example, if there's 'image.jpg' and the @deduplication_index is set to 2,
|
113
114
|
# The stored file will be named as 'image(2).jpg'.
|
114
115
|
#
|
115
116
|
# === Parameters
|
116
117
|
#
|
117
|
-
# [
|
118
|
+
# [current_identifiers (Array[String])] List of identifiers for already-stored files
|
118
119
|
#
|
119
|
-
def deduplicate(
|
120
|
+
def deduplicate(current_identifiers)
|
120
121
|
@deduplication_index = nil
|
121
|
-
return unless
|
122
|
+
return unless current_identifiers.include?(identifier)
|
122
123
|
|
123
|
-
(
|
124
|
+
(1..current_identifiers.size + 1).each do |i|
|
124
125
|
@deduplication_index = i
|
125
|
-
break unless
|
126
|
+
break unless current_identifiers.include?(identifier)
|
126
127
|
end
|
127
128
|
end
|
128
129
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "active_support/core_ext/object/deep_dup"
|
2
|
+
|
1
3
|
module CarrierWave
|
2
4
|
module Uploader
|
3
5
|
module Versions
|
@@ -25,6 +27,17 @@ module CarrierWave
|
|
25
27
|
@klass.processors = []
|
26
28
|
@klass.version_options = @options
|
27
29
|
@klass.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
30
|
+
# Define the enable_processing method for versions so they get the
|
31
|
+
# value from the parent class unless explicitly overwritten
|
32
|
+
def self.enable_processing(value=nil)
|
33
|
+
self.enable_processing = value if value
|
34
|
+
if defined?(@enable_processing) && !@enable_processing.nil?
|
35
|
+
@enable_processing
|
36
|
+
else
|
37
|
+
superclass.enable_processing
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
28
41
|
# Regardless of what is set in the parent uploader, do not enforce the
|
29
42
|
# move_to_cache config option on versions because it moves the original
|
30
43
|
# file to the version's target file.
|
data/lib/carrierwave/version.rb
CHANGED
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.
|
4
|
+
version: 3.0.2
|
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-
|
11
|
+
date: 2023-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|