activestorage 6.0.0 → 6.0.1.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activestorage might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 716b00e8dcc27ec9df016cff558ecce99f31470d58bbc7efe3a495b7ab272722
4
- data.tar.gz: 2986c8c1b288f85025be8fc2f768c6c4370c36b593a81ff68599e1d3e691d7b7
3
+ metadata.gz: 6d424efd1fa5c4046399c3274aca014257a2e72230feaf69e3aa7217ad65fc21
4
+ data.tar.gz: a1d549b32cd85fe13d6577ade41f2269588ab483b4a3e6c4f376a6c3ff9feeeb
5
5
  SHA512:
6
- metadata.gz: c51640d41c7223552bdf418f1993af9fc49f73c24f002323e7deefcb8610dfddad022a566fb60a8c608081ae39d563e5940f092c291304c8074a0f8d0572120a
7
- data.tar.gz: c3c6b78ab356d557188ddd05dd8c033bdb2e55b7bde8c0443d0d9b4373d8da081b7f450c2edc1efb0f312d69f5cbd7b8517c6b249160c3719172dc473be88a3f
6
+ metadata.gz: 84ed4b45a68bdf07bbe8b994d07338eecfe552a5fe37c98913dbcd0e5f3aa67328571de163cceac14c836533ffd1d3e06af6177614777415f110f05eab2b305c
7
+ data.tar.gz: 9c5824e5f4a5084ef5635abd5f15ecc6182f6a713cafcc4959aa6873d0c701722df149278f6bc27c7d9ac7ef2dca122595830ecb4e98d7199b7f5629c5e71f7a
@@ -1,3 +1,16 @@
1
+ ## Rails 6.0.1.rc1 (October 31, 2019) ##
2
+
3
+ * `ActiveStorage::AnalyzeJob`s are discarded on `ActiveRecord::RecordNotFound` errors.
4
+
5
+ *George Claghorn*
6
+
7
+ * Blobs are recorded in the database before being uploaded to the service.
8
+ This fixes that generated blob keys could silently collide, leading to
9
+ data loss.
10
+
11
+ *Julik Tarkhanov*
12
+
13
+
1
14
  ## Rails 6.0.0 (August 16, 2019) ##
2
15
 
3
16
  * No changes.
@@ -4,6 +4,7 @@
4
4
  class ActiveStorage::AnalyzeJob < ActiveStorage::BaseJob
5
5
  queue_as { ActiveStorage.queues[:analysis] }
6
6
 
7
+ discard_on ActiveRecord::RecordNotFound
7
8
  retry_on ActiveStorage::IntegrityError, attempts: 10, wait: :exponentially_longer
8
9
 
9
10
  def perform(blob)
@@ -5,8 +5,9 @@ require "active_storage/downloader"
5
5
  # A blob is a record that contains the metadata about a file and a key for where that file resides on the service.
6
6
  # Blobs can be created in two ways:
7
7
  #
8
- # 1. Subsequent to the file being uploaded server-side to the service via <tt>create_after_upload!</tt>.
9
- # 2. Ahead of the file being directly uploaded client-side to the service via <tt>create_before_direct_upload!</tt>.
8
+ # 1. Ahead of the file being uploaded server-side to the service, via <tt>create_and_upload!</tt>. A rewindable
9
+ # <tt>io</tt> with the file contents must be available at the server for this operation.
10
+ # 2. Ahead of the file being directly uploaded client-side to the service, via <tt>create_before_direct_upload!</tt>.
10
11
  #
11
12
  # The first option doesn't require any client-side JavaScript integration, and can be used by any other back-end
12
13
  # service that deals with files. The second option is faster, since you're not using your own server as a staging
@@ -63,14 +64,23 @@ class ActiveStorage::Blob < ActiveRecord::Base
63
64
  end
64
65
  end
65
66
 
66
- # Returns a saved blob instance after the +io+ has been uploaded to the service. Note, the blob is first built,
67
- # then the +io+ is uploaded, then the blob is saved. This is done this way to avoid uploading (which may take
68
- # time), while having an open database transaction.
67
+ def create_after_unfurling!(io:, filename:, content_type: nil, metadata: nil, identify: true, record: nil) #:nodoc:
68
+ build_after_unfurling(io: io, filename: filename, content_type: content_type, metadata: metadata, identify: identify).tap(&:save!)
69
+ end
70
+
71
+ # Creates a new blob instance and then uploads the contents of the given <tt>io</tt> to the
72
+ # service. The blob instance is saved before the upload begins to avoid clobbering another due
73
+ # to key collisions.
74
+ #
69
75
  # When providing a content type, pass <tt>identify: false</tt> to bypass automatic content type inference.
70
- def create_after_upload!(io:, filename:, content_type: nil, metadata: nil, identify: true)
71
- build_after_upload(io: io, filename: filename, content_type: content_type, metadata: metadata, identify: identify).tap(&:save!)
76
+ def create_and_upload!(io:, filename:, content_type: nil, metadata: nil, identify: true, record: nil)
77
+ create_after_unfurling!(io: io, filename: filename, content_type: content_type, metadata: metadata, identify: identify).tap do |blob|
78
+ blob.upload_without_unfurling(io)
79
+ end
72
80
  end
73
81
 
82
+ alias_method :create_after_upload!, :create_and_upload!
83
+
74
84
  # Returns a saved blob _without_ uploading a file to the service. This blob will point to a key where there is
75
85
  # no file yet. It's intended to be used together with a client-side upload, which will first create the blob
76
86
  # in order to produce the signed URL for uploading. This signed URL points to the key generated by the blob.
@@ -165,8 +175,9 @@ class ActiveStorage::Blob < ActiveRecord::Base
165
175
  # and store that in +byte_size+ on the blob record. The content type is automatically extracted from the +io+ unless
166
176
  # you specify a +content_type+ and pass +identify+ as false.
167
177
  #
168
- # Normally, you do not have to call this method directly at all. Use the factory class methods of +build_after_upload+
169
- # and +create_after_upload!+.
178
+ # Normally, you do not have to call this method directly at all. Use the +create_and_upload!+ class method instead.
179
+ # If you do use this method directly, make sure you are using it on a persisted Blob as otherwise another blob's
180
+ # data might get overwritten on the service.
170
181
  def upload(io, identify: true)
171
182
  unfurl io, identify: identify
172
183
  upload_without_unfurling io
@@ -95,13 +95,13 @@ module ActiveStorage
95
95
  def #{name}=(attachables)
96
96
  if ActiveStorage.replace_on_assign_to_many
97
97
  attachment_changes["#{name}"] =
98
- if attachables.nil? || Array(attachables).none?
98
+ if Array(attachables).none?
99
99
  ActiveStorage::Attached::Changes::DeleteMany.new("#{name}", self)
100
100
  else
101
101
  ActiveStorage::Attached::Changes::CreateMany.new("#{name}", self, attachables)
102
102
  end
103
103
  else
104
- if !attachables.nil? || Array(attachables).any?
104
+ if Array(attachables).any?
105
105
  attachment_changes["#{name}"] =
106
106
  ActiveStorage::Attached::Changes::CreateMany.new("#{name}", self, #{name}.blobs + attachables)
107
107
  end
@@ -9,8 +9,8 @@ module ActiveStorage
9
9
  module VERSION
10
10
  MAJOR = 6
11
11
  MINOR = 0
12
- TINY = 0
13
- PRE = nil
12
+ TINY = 1
13
+ PRE = "rc1"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activestorage
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 6.0.1.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-16 00:00:00.000000000 Z
11
+ date: 2019-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 6.0.0
19
+ version: 6.0.1.rc1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 6.0.0
26
+ version: 6.0.1.rc1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activejob
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 6.0.0
33
+ version: 6.0.1.rc1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 6.0.0
40
+ version: 6.0.1.rc1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activerecord
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 6.0.0
47
+ version: 6.0.1.rc1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 6.0.0
54
+ version: 6.0.1.rc1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: marcel
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -150,8 +150,11 @@ homepage: https://rubyonrails.org
150
150
  licenses:
151
151
  - MIT
152
152
  metadata:
153
- source_code_uri: https://github.com/rails/rails/tree/v6.0.0/activestorage
154
- changelog_uri: https://github.com/rails/rails/blob/v6.0.0/activestorage/CHANGELOG.md
153
+ bug_tracker_uri: https://github.com/rails/rails/issues
154
+ changelog_uri: https://github.com/rails/rails/blob/v6.0.1.rc1/activestorage/CHANGELOG.md
155
+ documentation_uri: https://api.rubyonrails.org/v6.0.1.rc1/
156
+ mailing_list_uri: https://groups.google.com/forum/#!forum/rubyonrails-talk
157
+ source_code_uri: https://github.com/rails/rails/tree/v6.0.1.rc1/activestorage
155
158
  post_install_message:
156
159
  rdoc_options: []
157
160
  require_paths:
@@ -163,11 +166,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
163
166
  version: 2.5.0
164
167
  required_rubygems_version: !ruby/object:Gem::Requirement
165
168
  requirements:
166
- - - ">="
169
+ - - ">"
167
170
  - !ruby/object:Gem::Version
168
- version: '0'
171
+ version: 1.3.1
169
172
  requirements: []
170
- rubygems_version: 3.0.1
173
+ rubygems_version: 3.0.3
171
174
  signing_key:
172
175
  specification_version: 4
173
176
  summary: Local and cloud file storage framework.