debug-mtimes-false Set @mtimes exactly when @mtime_file exist and it is nonzero

When there are more than one invocations of `add`, the second (and
later) invocations will end up with `@mtimes = false`.

This arises because the first invocation leave an empty @mtime_file, and this leads to

File.opn(@mtime_file, 'w') # => an empty file
YAML.load_file(@mtime_file) # => false

Henceforth, we would end up with `@mtimes = false`, and this is bad
news for `#add`:

/Users/travis/.casher/bin/casherin `block in add': undefined method `[]=' for false:FalseClass (NoMethodError)
from /Users/travis/.casher/bin/casherin `map'
from /Users/travis/.casher/bin/casherin `add'
from /Users/travis/.casher/bin/casher:52:in `block in run'
from /Users/travis/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/timeout.rb:69:in `timeout'
from /Users/travis/.casher/bin/casher:52:in `run'
from /Users/travis/.casher/bin/casher:231:in `<main>'

We avoid this problem by doing two things:

1. Create @mtime_file only when md5deep is not available
2. Set @mtimes only when @mtime_file exists and it is not empty

Hiro Asari avatar Hiro Asari

Push event #227 passed

  • Ran for
  • Total time