diff options
author | George Claghorn <george@basecamp.com> | 2018-08-23 19:07:29 -0400 |
---|---|---|
committer | George Claghorn <george@basecamp.com> | 2018-08-23 19:07:29 -0400 |
commit | 3868648cae36fd64741135e3d33d7055e925879b (patch) | |
tree | 02fd70a21ba0831d9a544a3dbe8dcaba997d7e01 | |
parent | b204d167c5cfebd59f771d406178e371811ac43a (diff) | |
download | rails-3868648cae36fd64741135e3d33d7055e925879b.tar.gz rails-3868648cae36fd64741135e3d33d7055e925879b.tar.bz2 rails-3868648cae36fd64741135e3d33d7055e925879b.zip |
Revert "Merge pull request #33667 from cbothner/azure-service-swallowing-all-errors"
This reverts commit b204d167c5cfebd59f771d406178e371811ac43a, reversing
changes made to de6a200f82a3de399fa685d583503bc88dbc5e9f.
-rw-r--r-- | activestorage/CHANGELOG.md | 7 | ||||
-rw-r--r-- | activestorage/lib/active_storage/service/azure_storage_service.rb | 20 |
2 files changed, 7 insertions, 20 deletions
diff --git a/activestorage/CHANGELOG.md b/activestorage/CHANGELOG.md index 92e300a440..b592f79ca6 100644 --- a/activestorage/CHANGELOG.md +++ b/activestorage/CHANGELOG.md @@ -1,10 +1,3 @@ -* `ActiveStorage::Service::AzureStorageService` only handles specifically - relevant types of `Azure::Core::Http::HTTPError`. It previously obscured - other types of `HTTPError`, which is the azure-storage gem’s catch-all - exception class. - - *Cameron Bothner* - * `ActiveStorage::DiskController#show` generates a 404 Not Found response when the requested file is missing from the disk service. It previously raised `Errno::ENOENT`. diff --git a/activestorage/lib/active_storage/service/azure_storage_service.rb b/activestorage/lib/active_storage/service/azure_storage_service.rb index 4fde35bdeb..66aabc1f9f 100644 --- a/activestorage/lib/active_storage/service/azure_storage_service.rb +++ b/activestorage/lib/active_storage/service/azure_storage_service.rb @@ -19,8 +19,10 @@ module ActiveStorage def upload(key, io, checksum: nil) instrument :upload, key: key, checksum: checksum do - handle_errors do + begin blobs.create_block_blob(container, key, IO.try_convert(io) || io, content_md5: checksum) + rescue Azure::Core::Http::HTTPError + raise ActiveStorage::IntegrityError end end end @@ -53,8 +55,7 @@ module ActiveStorage instrument :delete, key: key do begin blobs.delete_blob(container, key) - rescue Azure::Core::Http::HTTPError => e - raise unless e.type == "BlobNotFound" + rescue Azure::Core::Http::HTTPError # Ignore files already deleted end end @@ -127,12 +128,8 @@ module ActiveStorage def blob_for(key) blobs.get_blob_properties(container, key) - rescue Azure::Core::Http::HTTPError => e - if e.type == "BlobNotFound" - false - else - raise - end + rescue Azure::Core::Http::HTTPError + false end def format_expiry(expires_in) @@ -158,11 +155,8 @@ module ActiveStorage def handle_errors yield rescue Azure::Core::Http::HTTPError => e - case e.type - when "BlobNotFound" + if e.type == "BlobNotFound" raise ActiveStorage::FileNotFoundError - when "Md5Mismatch" - raise ActiveStorage::IntegrityError else raise end |