guard / listen

The Listen gem listens to file modifications and notifies you about the changes.
https://rubygems.org/gems/listen
MIT License
1.93k stars 247 forks source link

Error when renaming folder #548

Closed simon1tan closed 2 years ago

simon1tan commented 3 years ago

Renamed a folder and received this error:

{:modified=>[], :added=>[], :removed=>["/mnt/data/services/auto/content/1"]} E, [2021-10-31T18:33:04.468750 #12499] ERROR -- : Exception rescued in listen-run_thread: NoMethodError: undefined method key?' for 1636153712.0:Float /var/lib/gems/2.7.0/gems/listen-3.7.0/lib/listen/record.rb:58:inblock in dir_entries' /var/lib/gems/2.7.0/gems/listen-3.7.0/lib/listen/record.rb:56:in transform_values' /var/lib/gems/2.7.0/gems/listen-3.7.0/lib/listen/record.rb:56:indir_entries' /var/lib/gems/2.7.0/gems/listen-3.7.0/lib/listen/directory.rb:12:in scan' /var/lib/gems/2.7.0/gems/listen-3.7.0/lib/listen/change.rb:60:ininvalidate' /var/lib/gems/2.7.0/gems/listen-3.7.0/lib/listen/adapter/base.rb:108:in _queue_change' /var/lib/gems/2.7.0/gems/listen-3.7.0/lib/listen/adapter/linux.rb:66:in_process_event' /var/lib/gems/2.7.0/gems/listen-3.7.0/lib/listen/adapter/base.rb:44:in block (2 levels) in configure' /var/lib/gems/2.7.0/gems/rb-inotify-0.10.1/lib/rb-inotify/notifier.rb:217:inblock in watch' /var/lib/gems/2.7.0/gems/rb-inotify-0.10.1/lib/rb-inotify/watcher.rb:41:in callback!' /var/lib/gems/2.7.0/gems/rb-inotify-0.10.1/lib/rb-inotify/event.rb:128:incallback!' /var/lib/gems/2.7.0/gems/rb-inotify-0.10.1/lib/rb-inotify/notifier.rb:264:in block in process' /var/lib/gems/2.7.0/gems/rb-inotify-0.10.1/lib/rb-inotify/notifier.rb:263:ineach' /var/lib/gems/2.7.0/gems/rb-inotify-0.10.1/lib/rb-inotify/notifier.rb:263:in process' /var/lib/gems/2.7.0/gems/rb-inotify-0.10.1/lib/rb-inotify/notifier.rb:236:inblock in run' /var/lib/gems/2.7.0/gems/rb-inotify-0.10.1/lib/rb-inotify/notifier.rb:232:in synchronize' /var/lib/gems/2.7.0/gems/rb-inotify-0.10.1/lib/rb-inotify/notifier.rb:232:inrun' /var/lib/gems/2.7.0/gems/listen-3.7.0/lib/listen/adapter/linux.rb:38:in _run' /var/lib/gems/2.7.0/gems/listen-3.7.0/lib/listen/adapter/base.rb:79:inblock in start' /var/lib/gems/2.7.0/gems/listen-3.7.0/lib/listen/thread.rb:26:in rescue_and_log' /var/lib/gems/2.7.0/gems/listen-3.7.0/lib/listen/thread.rb:18:inblock in new' --- Thread.new --- /var/lib/gems/2.7.0/gems/listen-3.7.0/lib/listen/adapter/base.rb:75:in start' /usr/lib/ruby/2.7.0/forwardable.rb:235:instart' /var/lib/gems/2.7.0/gems/listen-3.7.0/lib/listen/listener.rb:71:in block in <class:Listener>' /var/lib/gems/2.7.0/gems/listen-3.7.0/lib/listen/fsm.rb:124:ininstance_eval' /var/lib/gems/2.7.0/gems/listen-3.7.0/lib/listen/fsm.rb:124:in call' /var/lib/gems/2.7.0/gems/listen-3.7.0/lib/listen/fsm.rb:105:intransition_with_callbacks!' /var/lib/gems/2.7.0/gems/listen-3.7.0/lib/listen/fsm.rb:72:in transition' /var/lib/gems/2.7.0/gems/listen-3.7.0/lib/listen/listener.rb:92:instart'

Code is basically the same as example except Listen.to(ARGV[0])

ColinDKelley commented 3 years ago

Thanks for reporting this bug.

It looks like this code expects a hash in values, but it's actually a floating point timestamp. I'm still looking to see where that came from.

        values.key?(:mtime) ? values : {}
ColinDKelley commented 2 years ago

@simon1tan I was able to create a failing test and put in a fix here: https://github.com/guard/listen/pull/552 Look good?

ColinDKelley commented 2 years ago

Fixed in v3.7.1.