CSV.open call in csv_source.rb is leaking file handle
NickDiMucci opened this issue · 0 comments
csv-diff/lib/csv-diff/csv_source.rb
Line 107 in abff443
CSV.open has a design flaw where the underlying file handle gets lost if you chain a call after it. This is an issue if you need to, for one example, delete the file used as the source after you are done diffing/parsing/etc. The CSV class doesn't let go of the handle and you can't get it back.
I have opened a PR to fix this.
To reproduce the issue, simply call CSVDiff.new with two files and then try to call File.delete on them.
And for context, I have a use case where I download two, third party CSV reports, do a diff on them to obtain an array of the differences (using CSVDiff) and need to delete the downloaded reports once I'm done. This is how I discovered the issue.