diff options
-rw-r--r-- | activestorage/CHANGELOG.md | 6 | ||||
-rw-r--r-- | activestorage/app/controllers/active_storage/disk_controller.rb | 2 | ||||
-rw-r--r-- | activestorage/test/controllers/disk_controller_test.rb | 8 |
3 files changed, 16 insertions, 0 deletions
diff --git a/activestorage/CHANGELOG.md b/activestorage/CHANGELOG.md index 8e11146121..b592f79ca6 100644 --- a/activestorage/CHANGELOG.md +++ b/activestorage/CHANGELOG.md @@ -1,3 +1,9 @@ +* `ActiveStorage::DiskController#show` generates a 404 Not Found response when + the requested file is missing from the disk service. It previously raised + `Errno::ENOENT`. + + *Cameron Bothner* + * `ActiveStorage::Blob#download` and `ActiveStorage::Blob#open` raise `ActiveStorage::FileNotFoundError` when the corresponding file is missing from the storage service. Services translate service-specific missing object diff --git a/activestorage/app/controllers/active_storage/disk_controller.rb b/activestorage/app/controllers/active_storage/disk_controller.rb index 75cc11d6ff..7bd641ab9a 100644 --- a/activestorage/app/controllers/active_storage/disk_controller.rb +++ b/activestorage/app/controllers/active_storage/disk_controller.rb @@ -13,6 +13,8 @@ class ActiveStorage::DiskController < ActiveStorage::BaseController else head :not_found end + rescue Errno::ENOENT + head :not_found end def update diff --git a/activestorage/test/controllers/disk_controller_test.rb b/activestorage/test/controllers/disk_controller_test.rb index c053052f6f..4bc61d13f3 100644 --- a/activestorage/test/controllers/disk_controller_test.rb +++ b/activestorage/test/controllers/disk_controller_test.rb @@ -31,6 +31,14 @@ class ActiveStorage::DiskControllerTest < ActionDispatch::IntegrationTest assert_equal " worl", response.body end + test "showing blob that does not exist" do + blob = create_blob + blob.delete + + get blob.service_url + assert_response :not_found + end + test "directly uploading blob with integrity" do data = "Something else entirely!" |