diff --git a/lib/valkyrie/specs/shared_specs/storage_adapter.rb b/lib/valkyrie/specs/shared_specs/storage_adapter.rb index e9a4846f..8f5b4a80 100644 --- a/lib/valkyrie/specs/shared_specs/storage_adapter.rb +++ b/lib/valkyrie/specs/shared_specs/storage_adapter.rb @@ -30,17 +30,18 @@ class Valkyrie::Specs::CustomResource < Valkyrie::Resource expect(uploaded_file.valid?(digests: { sha1: sha1 })).to be true end - it "doesn't open a file handle on discovery" do + it "doesn't leave a file handle open on upload/find_by" do + # No file handle left open from upload. resource = Valkyrie::Specs::CustomResource.new(id: "testdiscovery") pre_open_files = open_files uploaded_file = storage_adapter.upload(file: file, original_filename: 'foo.jpg', resource: resource, fake_upload_argument: true) file.close expect(pre_open_files.size).to eq open_files.size + # No file handle left open from find_by pre_open_files = open_files the_file = storage_adapter.find_by(id: uploaded_file.id) expect(the_file).to be_kind_of Valkyrie::StorageAdapter::File - # the_file.io expect(pre_open_files.size).to eq open_files.size end diff --git a/lib/valkyrie/storage/disk.rb b/lib/valkyrie/storage/disk.rb index d2138a0f..280c7c25 100644 --- a/lib/valkyrie/storage/disk.rb +++ b/lib/valkyrie/storage/disk.rb @@ -41,9 +41,9 @@ def find_by(id:) raise Valkyrie::StorageAdapter::FileNotFound end - ## Lazy file takes open parameters but doesn't open up a file handle. This - # way StorageAdapter#find_by doesn't open a handle silently and never clean - # up after itself. + ## LazyFile takes File.open parameters but doesn't leave a file handle open on + # instantiation. This way StorageAdapter#find_by doesn't open a handle + # silently and never clean up after itself. class LazyFile def self.open(path, mode) # Open the file regularly and close it, so it can error if it doesn't