activestorage 6.0.0.beta3 → 6.0.0.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: 1f4f8dc7b792435184bfba73a933d3169ed962175e6ac4538801187432878377
4
- data.tar.gz: d72fe2a07e25afae1b3562ee20d95625eb7ccf7b659174c4add9d87a54bd7688
3
+ metadata.gz: c8580843508ea2f503d6033f26c93d245915f3bc909466345df8720cc66f5f9b
4
+ data.tar.gz: 25f095c896e240cba0fa842b402a28d4520b13eb53efbb9bb205d29c05a18aa8
5
5
  SHA512:
6
- metadata.gz: 35588376c7e0bd863f76ef9919066f4c8c1ad1d33fc103edc70b4f0ab677d9e4b0f07847a27d13cc66cf654bf2da9307c04109e167a2d8c1b258ddc37af09e72
7
- data.tar.gz: 107e06b3a5dce31df95a0e45633efbcb14a18072ffcfa15768987361477b8e806b3c37bb460ae98202b2e30e6b1f9852ca644c4491e1f763ad6dc743d870767e
6
+ metadata.gz: 6937e460ca8cd6ebd3e42543e5afb13bc96f7980e3026ebcd59dac443e955840e28652ffb4a8a68f022df63a33ad3d68a071a012eb9bedf2f3c99dba10c793a9
7
+ data.tar.gz: 0aa39714af36c775897f663ed28dde3113e28cca23ec4e579d2004d384520657ea49c6c32f67bc3a878450af6edea623a475df984782f165cfd099d9a093554c
@@ -1,3 +1,16 @@
1
+ ## Rails 6.0.0.rc1 (April 24, 2019) ##
2
+
3
+ * Don't raise when analyzing an image whose type is unsupported by ImageMagick.
4
+
5
+ Fixes #36065.
6
+
7
+ *Guilherme Mansur*
8
+
9
+ * Permit generating variants of BMP images.
10
+
11
+ *Younes Serraj*
12
+
13
+
1
14
  ## Rails 6.0.0.beta3 (March 11, 2019) ##
2
15
 
3
16
  * No changes.
data/README.md CHANGED
@@ -4,7 +4,9 @@ Active Storage makes it simple to upload and reference files in cloud services l
4
4
 
5
5
  Files can be uploaded from the server to the cloud or directly from the client to the cloud.
6
6
 
7
- Image files can furthermore be transformed using on-demand variants for quality, aspect ratio, size, or any other [MiniMagick](https://github.com/minimagick/minimagick) or [Vips](http://www.rubydoc.info/gems/ruby-vips/Vips/Image) supported transformation.
7
+ Image files can furthermore be transformed using on-demand variants for quality, aspect ratio, size, or any other [MiniMagick](https://github.com/minimagick/minimagick) or [Vips](https://www.rubydoc.info/gems/ruby-vips/Vips/Image) supported transformation.
8
+
9
+ You can read more about Active Storage in the [Active Storage Overview](https://edgeguides.rubyonrails.org/active_storage_overview.html) guide.
8
10
 
9
11
  ## Compared to other storage solutions
10
12
 
@@ -149,7 +151,7 @@ Active Storage is released under the [MIT License](https://opensource.org/licens
149
151
 
150
152
  API documentation is at:
151
153
 
152
- * http://api.rubyonrails.org
154
+ * https://api.rubyonrails.org
153
155
 
154
156
  Bug reports for the Ruby on Rails project can be filed here:
155
157
 
@@ -3,7 +3,7 @@
3
3
  # Serves files stored with the disk service in the same way that the cloud services do.
4
4
  # This means using expiring, signed URLs that are meant for immediate access, not permanent linking.
5
5
  # Always go through the BlobsController, or your own authenticated controller, rather than directly
6
- # to the service url.
6
+ # to the service URL.
7
7
  class ActiveStorage::DiskController < ActiveStorage::BaseController
8
8
  skip_forgery_protection
9
9
 
@@ -46,3 +46,5 @@ class ActiveStorage::Attachment < ActiveRecord::Base
46
46
  record.attachment_reflections[name]&.options[:dependent]
47
47
  end
48
48
  end
49
+
50
+ ActiveSupport.run_load_hooks :active_storage_attachment, ActiveStorage::Attachment
@@ -193,17 +193,18 @@ class ActiveStorage::Blob < ActiveRecord::Base
193
193
  #
194
194
  # The tempfile's name is prefixed with +ActiveStorage-+ and the blob's ID. Its extension matches that of the blob.
195
195
  #
196
- # By default, the tempfile is created in <tt>Dir.tmpdir</tt>. Pass +tempdir:+ to create it in a different directory:
196
+ # By default, the tempfile is created in <tt>Dir.tmpdir</tt>. Pass +tmpdir:+ to create it in a different directory:
197
197
  #
198
- # blob.open(tempdir: "/path/to/tmp") do |file|
198
+ # blob.open(tmpdir: "/path/to/tmp") do |file|
199
199
  # # ...
200
200
  # end
201
201
  #
202
202
  # The tempfile is automatically closed and unlinked after the given block is executed.
203
203
  #
204
204
  # Raises ActiveStorage::IntegrityError if the downloaded data does not match the blob's checksum.
205
- def open(tempdir: nil, &block)
206
- ActiveStorage::Downloader.new(self, tempdir: tempdir).download_blob_to_tempfile(&block)
205
+ def open(tmpdir: nil, &block)
206
+ service.open key, checksum: checksum,
207
+ name: [ "ActiveStorage-#{id}-", filename.extension_with_delimiter ], tmpdir: tmpdir, &block
207
208
  end
208
209
 
209
210
 
@@ -272,6 +273,6 @@ class ActiveStorage::Blob < ActiveRecord::Base
272
273
  { content_type: content_type }
273
274
  end
274
275
  end
275
-
276
- ActiveSupport.run_load_hooks(:active_storage_blob, self)
277
276
  end
277
+
278
+ ActiveSupport.run_load_hooks :active_storage_blob, ActiveStorage::Blob
@@ -40,7 +40,7 @@ class ActiveStorage::Variation
40
40
  end
41
41
 
42
42
  def initialize(transformations)
43
- @transformations = transformations
43
+ @transformations = transformations.deep_symbolize_keys
44
44
  end
45
45
 
46
46
  # Accepts a File object, performs the +transformations+ against it, and
@@ -64,7 +64,7 @@ class ActiveStorage::Variation
64
64
  begin
65
65
  require "image_processing"
66
66
  rescue LoadError
67
- ActiveSupport::Deprecation.warn <<~WARNING
67
+ ActiveSupport::Deprecation.warn <<~WARNING.squish
68
68
  Generating image variants will require the image_processing gem in Rails 6.1.
69
69
  Please add `gem 'image_processing', '~> 1.2'` to your Gemfile.
70
70
  WARNING
@@ -1,6 +1,8 @@
1
1
  class AddForeignKeyConstraintToActiveStorageAttachmentsForBlobId < ActiveRecord::Migration[6.0]
2
2
  def up
3
- unless foreign_key_exists?(:active_storage_attachments, column: :blob_id)
3
+ return if foreign_key_exists?(:active_storage_attachments, column: :blob_id)
4
+
5
+ if table_exists?(:active_storage_blobs)
4
6
  add_foreign_key :active_storage_attachments, :active_storage_blobs, column: :blob_id
5
7
  end
6
8
  end
@@ -24,14 +24,14 @@ module ActiveStorage
24
24
  private
25
25
  # Downloads the blob to a tempfile on disk. Yields the tempfile.
26
26
  def download_blob_to_tempfile(&block) #:doc:
27
- blob.open tempdir: tempdir, &block
27
+ blob.open tmpdir: tmpdir, &block
28
28
  end
29
29
 
30
30
  def logger #:doc:
31
31
  ActiveStorage.logger
32
32
  end
33
33
 
34
- def tempdir #:doc:
34
+ def tmpdir #:doc:
35
35
  Dir.tmpdir
36
36
  end
37
37
  end
@@ -25,17 +25,24 @@ module ActiveStorage
25
25
  { width: image.width, height: image.height }
26
26
  end
27
27
  end
28
- rescue LoadError
29
- logger.info "Skipping image analysis because the mini_magick gem isn't installed"
30
- {}
31
28
  end
32
29
 
33
30
  private
34
31
  def read_image
35
32
  download_blob_to_tempfile do |file|
36
33
  require "mini_magick"
37
- yield MiniMagick::Image.new(file.path)
34
+ image = MiniMagick::Image.new(file.path)
35
+
36
+ if image.valid?
37
+ yield image
38
+ else
39
+ logger.info "Skipping image analysis because ImageMagick doesn't support the file"
40
+ {}
41
+ end
38
42
  end
43
+ rescue LoadError
44
+ logger.info "Skipping image analysis because the mini_magick gem isn't installed"
45
+ {}
39
46
  end
40
47
 
41
48
  def rotated_image?(image)
@@ -30,6 +30,7 @@ module ActiveStorage
30
30
 
31
31
  def save
32
32
  record.public_send("#{name}_attachment=", attachment)
33
+ record.public_send("#{name}_blob=", blob)
33
34
  end
34
35
 
35
36
  private
@@ -2,24 +2,23 @@
2
2
 
3
3
  module ActiveStorage
4
4
  class Downloader #:nodoc:
5
- def initialize(blob, tempdir: nil)
6
- @blob = blob
7
- @tempdir = tempdir
5
+ attr_reader :service
6
+
7
+ def initialize(service)
8
+ @service = service
8
9
  end
9
10
 
10
- def download_blob_to_tempfile
11
- open_tempfile do |file|
12
- download_blob_to file
13
- verify_integrity_of file
11
+ def open(key, checksum:, name: "ActiveStorage-", tmpdir: nil)
12
+ open_tempfile(name, tmpdir) do |file|
13
+ download key, file
14
+ verify_integrity_of file, checksum: checksum
14
15
  yield file
15
16
  end
16
17
  end
17
18
 
18
19
  private
19
- attr_reader :blob, :tempdir
20
-
21
- def open_tempfile
22
- file = Tempfile.open([ "ActiveStorage-#{blob.id}-", blob.filename.extension_with_delimiter ], tempdir)
20
+ def open_tempfile(name, tmpdir = nil)
21
+ file = Tempfile.open(name, tmpdir)
23
22
 
24
23
  begin
25
24
  yield file
@@ -28,15 +27,15 @@ module ActiveStorage
28
27
  end
29
28
  end
30
29
 
31
- def download_blob_to(file)
30
+ def download(key, file)
32
31
  file.binmode
33
- blob.download { |chunk| file.write(chunk) }
32
+ service.download(key) { |chunk| file.write(chunk) }
34
33
  file.flush
35
34
  file.rewind
36
35
  end
37
36
 
38
- def verify_integrity_of(file)
39
- unless Digest::MD5.file(file).base64digest == blob.checksum
37
+ def verify_integrity_of(file, checksum:)
38
+ unless Digest::MD5.file(file).base64digest == checksum
40
39
  raise ActiveStorage::IntegrityError
41
40
  end
42
41
  end
@@ -1,6 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "rails"
4
+ require "action_controller/railtie"
5
+ require "active_job/railtie"
6
+ require "active_record/railtie"
7
+
4
8
  require "active_storage"
5
9
 
6
10
  require "active_storage/previewer/poppler_pdf_previewer"
@@ -29,6 +33,7 @@ module ActiveStorage
29
33
  image/jpeg
30
34
  image/pjpeg
31
35
  image/tiff
36
+ image/bmp
32
37
  image/vnd.adobe.photoshop
33
38
  image/vnd.microsoft.icon
34
39
  )
@@ -52,6 +57,7 @@ module ActiveStorage
52
57
  image/jpg
53
58
  image/jpeg
54
59
  image/tiff
60
+ image/bmp
55
61
  image/vnd.adobe.photoshop
56
62
  image/vnd.microsoft.icon
57
63
  application/pdf
@@ -10,7 +10,7 @@ module ActiveStorage
10
10
  MAJOR = 6
11
11
  MINOR = 0
12
12
  TINY = 0
13
- PRE = "beta3"
13
+ PRE = "rc1"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -26,7 +26,7 @@ module ActiveStorage
26
26
  private
27
27
  # Downloads the blob to a tempfile on disk. Yields the tempfile.
28
28
  def download_blob_to_tempfile(&block) #:doc:
29
- blob.open tempdir: tempdir, &block
29
+ blob.open tmpdir: tmpdir, &block
30
30
  end
31
31
 
32
32
  # Executes a system command, capturing its binary output in a tempfile. Yields the tempfile.
@@ -42,7 +42,7 @@ module ActiveStorage
42
42
  # end
43
43
  # end
44
44
  #
45
- # The output tempfile is opened in the directory returned by #tempdir.
45
+ # The output tempfile is opened in the directory returned by #tmpdir.
46
46
  def draw(*argv) #:doc:
47
47
  open_tempfile do |file|
48
48
  instrument :preview, key: blob.key do
@@ -54,7 +54,7 @@ module ActiveStorage
54
54
  end
55
55
 
56
56
  def open_tempfile
57
- tempfile = Tempfile.open("ActiveStorage-", tempdir)
57
+ tempfile = Tempfile.open("ActiveStorage-", tmpdir)
58
58
 
59
59
  begin
60
60
  yield tempfile
@@ -77,7 +77,7 @@ module ActiveStorage
77
77
  ActiveStorage.logger
78
78
  end
79
79
 
80
- def tempdir #:doc:
80
+ def tmpdir #:doc:
81
81
  Dir.tmpdir
82
82
  end
83
83
  end
@@ -82,6 +82,10 @@ module ActiveStorage
82
82
  raise NotImplementedError
83
83
  end
84
84
 
85
+ def open(*args, &block)
86
+ ActiveStorage::Downloader.new(self).open(*args, &block)
87
+ end
88
+
85
89
  # Delete the file at the +key+.
86
90
  def delete(key)
87
91
  raise NotImplementedError
@@ -131,7 +131,7 @@ module ActiveStorage
131
131
  end
132
132
 
133
133
  def bucket
134
- @bucket ||= client.bucket(config.fetch(:bucket))
134
+ @bucket ||= client.bucket(config.fetch(:bucket), skip_lookup: true)
135
135
  end
136
136
 
137
137
  def client
@@ -22,7 +22,7 @@ module ActiveStorage
22
22
  def operations
23
23
  transformations.each_with_object([]) do |(name, argument), list|
24
24
  if name.to_s == "combine_options"
25
- ActiveSupport::Deprecation.warn <<~WARNING
25
+ ActiveSupport::Deprecation.warn <<~WARNING.squish
26
26
  Active Storage's ImageProcessing transformer doesn't support :combine_options,
27
27
  as it always generates a single ImageMagick command. Passing :combine_options will
28
28
  not be supported in Rails 6.1.
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.beta3
4
+ version: 6.0.0.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-03-13 00:00:00.000000000 Z
11
+ date: 2019-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -16,28 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 6.0.0.beta3
19
+ version: 6.0.0.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.beta3
26
+ version: 6.0.0.rc1
27
+ - !ruby/object:Gem::Dependency
28
+ name: activejob
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 6.0.0.rc1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 6.0.0.rc1
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: activerecord
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - '='
32
46
  - !ruby/object:Gem::Version
33
- version: 6.0.0.beta3
47
+ version: 6.0.0.rc1
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - '='
39
53
  - !ruby/object:Gem::Version
40
- version: 6.0.0.beta3
54
+ version: 6.0.0.rc1
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: marcel
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -132,12 +146,12 @@ files:
132
146
  - lib/active_storage/transformers/transformer.rb
133
147
  - lib/active_storage/version.rb
134
148
  - lib/tasks/activestorage.rake
135
- homepage: http://rubyonrails.org
149
+ homepage: https://rubyonrails.org
136
150
  licenses:
137
151
  - MIT
138
152
  metadata:
139
- source_code_uri: https://github.com/rails/rails/tree/v6.0.0.beta3/activestorage
140
- changelog_uri: https://github.com/rails/rails/blob/v6.0.0.beta3/activestorage/CHANGELOG.md
153
+ source_code_uri: https://github.com/rails/rails/tree/v6.0.0.rc1/activestorage
154
+ changelog_uri: https://github.com/rails/rails/blob/v6.0.0.rc1/activestorage/CHANGELOG.md
141
155
  post_install_message:
142
156
  rdoc_options: []
143
157
  require_paths: