jnicklas/carrierwave — comment on commit ba8b9d4de5519a367d7731662d8efa8472c2f999
File:  line 0
By yfeldblum:

I think part of the issue is that there needs to be a convention on who closes the file. Typically the class/method that opens the file must close it. But here, `SanitizedFile` either returns an already-opened `File` or newly opens opens the `File` and returns it, while `Storage::Fog` gets a `File` which has been opened but has no idea whether it's supposed to `#close` it.

Preferably, `Storage::Fog` should be the one to call `File.open` (if it can, that is, if `new_file` has a `path` that can be passed to `File.open`), and it should have an ensure block which always calls `File#close`. That way, since the file is opened and closed in the same method, and the close happens in an ensure block, the underlying low-level behavior of the method is clear.