yt icon indicating copy to clipboard operation
yt copied to clipboard

`Video#empty?` causes unexpected behaviour

Open pavelbonda opened this issue 3 years ago • 1 comments

Recently I found that usage of #present? or #blank? methods on a video object causes additional status queries

This is because of ActiveSupport's definition of #blank? method

# @return [true, false]
def blank?
  respond_to?(:empty?) ? !!empty? : !self
end

It calls #empty? method on a video object

# @return [Boolean] whether the video failed to upload to YouTube because
#   the video file is empty.
def empty?
  status.failure_reason == 'emptyFile'
end

Which was quite quirky for me , I didn't expect such behaviour

As a quick fix I would overwrite #blank? for a Video

What do you think?

pavelbonda avatar Apr 06 '22 11:04 pavelbonda

I'm not sure, probably we should rename empty? or document somewhere that not to use blank? on videos.

kangkyu avatar Sep 27 '23 05:09 kangkyu