Skip to content

Commit

Permalink
Fix a bug where no files found would be a divide by zero error
Browse files Browse the repository at this point in the history
  • Loading branch information
cguess committed Oct 17, 2024
1 parent 9362ca9 commit 56ac16c
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 23 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ gem "sorbet-static-and-runtime"

group :development do
gem "tapioca", require: false
gem "pry-byebug"
end

gem "terrapin"
44 changes: 23 additions & 21 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
PATH
remote: .
specs:
eikon (0.1.10)
eikon (0.1.12)
mutex_m
ruby-vips (~> 2.1)
sorbet-runtime (>= 0.5.9204)
terrapin (~> 0.6.0)
Expand Down Expand Up @@ -29,12 +30,14 @@ GEM
tzinfo (~> 2.0)
ast (2.4.2)
builder (3.2.4)
byebug (11.1.3)
climate_control (0.2.0)
coderay (1.1.3)
concurrent-ruby (1.1.10)
crass (1.0.6)
diff-lcs (1.5.0)
erubi (1.11.0)
ffi (1.15.5)
ffi (1.16.3)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
json (2.6.2)
Expand All @@ -44,13 +47,20 @@ GEM
method_source (1.0.0)
mini_portile2 (2.8.0)
minitest (5.16.3)
mutex_m (0.2.0)
netrc (0.11.0)
nokogiri (1.13.9)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
parallel (1.22.1)
parser (3.1.2.1)
ast (~> 2.4.1)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.10.1)
byebug (~> 11.0)
pry (>= 0.13, < 0.15)
racc (1.6.0)
rack (2.2.4)
rack-test (2.0.2)
Expand Down Expand Up @@ -108,24 +118,15 @@ GEM
rubocop-performance (~> 1.11)
rubocop-rails (~> 2.0)
ruby-progressbar (1.11.0)
ruby-vips (2.1.4)
ruby-vips (2.2.0)
ffi (~> 1.12)
sorbet (0.5.10549)
sorbet-static (= 0.5.10549)
sorbet-runtime (0.5.10549)
sorbet-static (0.5.10549-universal-darwin-14)
sorbet-static (0.5.10549-universal-darwin-15)
sorbet-static (0.5.10549-universal-darwin-16)
sorbet-static (0.5.10549-universal-darwin-17)
sorbet-static (0.5.10549-universal-darwin-18)
sorbet-static (0.5.10549-universal-darwin-19)
sorbet-static (0.5.10549-universal-darwin-20)
sorbet-static (0.5.10549-universal-darwin-21)
sorbet-static (0.5.10549-universal-darwin-22)
sorbet-static (0.5.10549-x86_64-linux)
sorbet-static-and-runtime (0.5.10549)
sorbet (= 0.5.10549)
sorbet-runtime (= 0.5.10549)
sorbet (0.5.11604)
sorbet-static (= 0.5.11604)
sorbet-runtime (0.5.11604)
sorbet-static (0.5.11604-universal-darwin)
sorbet-static-and-runtime (0.5.11604)
sorbet (= 0.5.11604)
sorbet-runtime (= 0.5.11604)
spoom (1.1.12)
sorbet (>= 0.5.9204)
sorbet-runtime (>= 0.5.9204)
Expand Down Expand Up @@ -157,11 +158,12 @@ GEM
zeitwerk (2.6.6)

PLATFORMS
ruby
arm64-darwin-23

DEPENDENCIES
eikon!
minitest (~> 5.0)
pry-byebug
rake (~> 12.0)
rubocop (~> 1.27)
rubocop-rails
Expand All @@ -172,4 +174,4 @@ DEPENDENCIES
terrapin

BUNDLED WITH
2.3.11
2.5.22
3 changes: 2 additions & 1 deletion eikon.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
spec.description = "A small pure-Ruby (for now) implementation of DHash"
spec.homepage = "https://www.github.com/cguess/eikon"
spec.license = "MIT"
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")

# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"

Expand All @@ -31,4 +31,5 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency "ruby-vips", "~> 2.1"
spec.add_runtime_dependency "terrapin", "~> 0.6.0"
spec.add_runtime_dependency "sorbet-runtime", ">= 0.5.9204"
spec.add_runtime_dependency "mutex_m"
end
2 changes: 1 addition & 1 deletion lib/eikon/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# typed: true

module Eikon
VERSION = "0.1.11".freeze
VERSION = "0.1.12".freeze
end
8 changes: 8 additions & 0 deletions lib/eikon/video_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ def remove_blank_shots(folder_path)
entry.downcase.end_with?(".jpeg")
end

# Somehow there's an emnpty list of files,
# This is going to exclusively be a bug in a different part of the code
# that is using this library, so we'll just make sure we don't break
if file_names.empty?
puts "No files found in the directory. This is likely a bug in the code that called this library."
return
end

# Get the average size of the files
total_size = file_names.reduce(0) do |sum, file_name|
sum + File.size("#{folder_path}/#{file_name}")
Expand Down

0 comments on commit 56ac16c

Please sign in to comment.