-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't error when size is called on a deleted file #1561
Don't error when size is called on a deleted file #1561
Conversation
+1. we're running into this issue as well |
…evious_file Don't error when size is called on a deleted file
Thanks @danielevans! |
we are running too, thanks |
I just got
When updating an image, i'm using latest carrierwave with rails 4. Thanks! |
@amartell-smx Looks like this didn't make it into the |
Got this message
With master, still i don't want to use master version on production, is there any way to workaround the Thanks! |
You could easily monkey-patch the fix in. require 'carrierwave/storage/fog'
class CarrierWave::Storage::Fog::File
def size
file.nil? ? 0 : file.content_length
end
end |
Actually it should be require 'carrierwave/storage/fog'
class CarrierWave::Storage::Fog::File
def size
file.nil? ? 0 : file.content_length
end
end Thanks! |
Gah, thanks. I edited mine to make sure nobody copy-pastes the bad code. |
Still not in the lastest release (0.11.0). Is there a reason not to release this ? I'll monkey-patch for the moment. |
Same problem with |
When using Fog and AWS and a new file is uploaded and the old file is missing
content_length
is called on nil, resulting in the inability to upload a new file.This change updates the
CarrierWave::Storage::Fog
class such that it will not error if this situation occurs and instead return a 0 file size.It seems that this change could also be made in https://github.com/carrierwaveuploader/carrierwave/blob/master/lib/carrierwave/sanitized_file.rb#L136 by reversing the conditional
(self.size.zero? && ! self.exists?)
, however the change in this PR seemed less invasive.The error caused by this issue: