listen 3.10.0 → 3.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e8eccc119beebe2f5153f7fdba4cd313d48c5c7e6334fa3dff5a44bcfbbb720
4
- data.tar.gz: be423bbdfe20ba4908fc97f9f0ac78bf26060c23e40ed5adf8c07925174245f4
3
+ metadata.gz: 67245b3e45ef5fa6fec5fb54a2b8af298c98caf521cea53ab29cc6b9fd15565f
4
+ data.tar.gz: ff8ca5d435fc3c409f845a0fbada5d3e7ce606d4a5962e9b07912245d08b7540
5
5
  SHA512:
6
- metadata.gz: 596b34d1eeb1d98519303cc0eaced3b4ba87e28b0311a1b96626519c9afd66d90a29b9cc95444d18cf2e42247ed99f9eda86a4d0fa09e19348b60f0f3f63af59
7
- data.tar.gz: 6c89b5bddcc73b889d58dc7364f8ed2f7d0c395eb9125215fb890bdd2a11fca9fad3bffc6da47cd83a43453169b40f1a94057c8dd818ea6c448863e594ae98c4
6
+ metadata.gz: 448354fa9e581471cfa7888f6478c439c9e2e0d1dcd9351adf962847f629efaea060cc629512e48f663119e7431b5e63d956df0cb24e5275a4827eff8544dbcc
7
+ data.tar.gz: e76261c0062d5655db30e316ebbbf4b0405c4321c19044ceae27743449ae92449ecb139650dec91ab6bf9999d0a40d748ca2d8760d9952aa886a02e0fac405b6
data/README.md CHANGED
@@ -25,7 +25,7 @@ The `listen` gem listens to file modifications and notifies you about the change
25
25
  * Support for plugins planned for future.
26
26
  * TCP functionality was removed in `listen` [3.0.0](https://github.com/guard/listen/releases/tag/v3.0.0) ([#319](https://github.com/guard/listen/issues/319), [#218](https://github.com/guard/listen/issues/218)). There are plans to extract this feature to separate gems ([#258](https://github.com/guard/listen/issues/258)), until this is finished, you can use by locking the `listen` gem to version `'~> 2.10'`.
27
27
  * Some filesystems won't work without polling (VM/Vagrant Shared folders, NFS, Samba, sshfs, etc.).
28
- * Windows and \*BSD adapter aren't continuously and automatically tested.
28
+ * \*BSD adapter isn't continuously and automatically tested.
29
29
  * OSX adapter has some performance limitations ([#342](https://github.com/guard/listen/issues/342)).
30
30
  * Listeners do not notify across forked processes, if you wish for multiple processes to receive change notifications you must [listen inside of each process](https://github.com/guard/listen/issues/398#issuecomment-223957952).
31
31
 
@@ -135,8 +135,6 @@ sleep
135
135
 
136
136
  Note: `:ignore` regexp patterns are evaluated against relative paths.
137
137
 
138
- Note: Ignoring paths does not improve performance, except when Polling ([#274](https://github.com/guard/listen/issues/274)).
139
-
140
138
  ### Only
141
139
 
142
140
  `Listen` watches all files (less the ignored ones) by default. If you want to only listen to a specific type of file (i.e., just `.rb` extension), you should use the `only` option/method.
@@ -88,7 +88,7 @@ module Listen
88
88
  private
89
89
 
90
90
  def _stop
91
- @run_thread&.kill
91
+ @run_thread&.kill&.join
92
92
  @run_thread = nil
93
93
  end
94
94
 
@@ -69,7 +69,7 @@ module Listen
69
69
  end
70
70
 
71
71
  def _stop
72
- @worker_thread&.kill
72
+ @worker_thread&.kill&.join
73
73
  super
74
74
  end
75
75
  end
@@ -18,7 +18,8 @@ module Listen
18
18
  Listen.logger.debug 'Adapter: considering polling ...'
19
19
  return Polling if options[:force_polling]
20
20
  Listen.logger.debug 'Adapter: considering optimized backend...'
21
- return _usable_adapter_class if _usable_adapter_class
21
+ adapter_class = _usable_adapter_class
22
+ return adapter_class if adapter_class
22
23
  Listen.logger.debug 'Adapter: falling back to polling...'
23
24
  _warn_polling_fallback(options)
24
25
  Polling
data/lib/listen/change.rb CHANGED
@@ -55,9 +55,7 @@ module Listen
55
55
  options = cookie ? { cookie: cookie } : {}
56
56
  @config.queue(type, change, watched_dir, rel_path, options)
57
57
  elsif type == :dir
58
- # NOTE: POSSIBLE RECURSION
59
- # TODO: fix - use a queue instead
60
- Directory.scan(self, rel_path, options)
58
+ _scan_directory(rel_path, options)
61
59
  elsif (change = File.change(record, rel_path)) && !options[:silence]
62
60
  @config.queue(:file, change, watched_dir, rel_path)
63
61
  end
@@ -65,5 +63,25 @@ module Listen
65
63
  # rubocop:enable Metrics/MethodLength
66
64
  # rubocop:enable Metrics/CyclomaticComplexity
67
65
  # rubocop:enable Metrics/PerceivedComplexity
66
+
67
+ private
68
+
69
+ def _scan_directory(rel_path, options)
70
+ @directory_scan_queue ||= []
71
+ @directory_scan_queue << [rel_path, options]
72
+ return if @scanning_directories
73
+
74
+ _drain_directory_scan_queue
75
+ end
76
+
77
+ def _drain_directory_scan_queue
78
+ @scanning_directories = true
79
+ @directory_scan_queue.each do |path, options|
80
+ Directory.scan(self, path, options)
81
+ end
82
+ ensure
83
+ @directory_scan_queue.clear
84
+ @scanning_directories = false
85
+ end
68
86
  end
69
87
  end
@@ -5,6 +5,8 @@ require 'set'
5
5
  module Listen
6
6
  # TODO: refactor (turn it into a normal object, cache the stat, etc)
7
7
  class Directory
8
+ MAX_RESCAN_ATTEMPTS = 5
9
+
8
10
  # rubocop:disable Metrics/MethodLength
9
11
  def self.scan(snapshot, rel_path, options)
10
12
  record = snapshot.record
@@ -23,6 +25,8 @@ module Listen
23
25
  rel_path, options.inspect, previous.inspect, current.inspect)
24
26
  end
25
27
 
28
+ rescan_attempts = 0
29
+ full_path = nil
26
30
  begin
27
31
  current.each do |full_path|
28
32
  type = ::File.lstat(full_path.to_s).directory? ? :dir : :file
@@ -31,8 +35,16 @@ module Listen
31
35
  end
32
36
  rescue Errno::ENOENT
33
37
  # The directory changed meanwhile, so rescan it
34
- current = Set.new(_children(path))
35
- retry
38
+ rescan_attempts += 1
39
+ if rescan_attempts <= MAX_RESCAN_ATTEMPTS
40
+ current = Set.new(_children(path))
41
+ retry
42
+ end
43
+
44
+ current.delete(full_path)
45
+ Listen.logger.debug do
46
+ "scan remained unstable after #{MAX_RESCAN_ATTEMPTS} rescans: #{path}"
47
+ end
36
48
  end
37
49
 
38
50
  # TODO: this is not tested properly
@@ -48,7 +60,9 @@ module Listen
48
60
  _async_changes(snapshot, path, previous, options)
49
61
  _change(snapshot, :file, rel_path, options)
50
62
  rescue
51
- Listen.logger.warn { format('scan DIED: %s:%s', $ERROR_INFO, $ERROR_POSITION * "\n") }
63
+ Listen.logger.warn do
64
+ "scan DIED: #{$ERROR_INFO}:#{$ERROR_POSITION * "\n"}"
65
+ end
52
66
  raise
53
67
  end
54
68
  # rubocop:enable Metrics/MethodLength
@@ -17,16 +17,21 @@ module Listen
17
17
  end
18
18
 
19
19
  def append_ignores(*regexps)
20
- prev_ignores = Array(@prev_silencer_options[:ignore])
21
- _reconfigure_silencer(ignore: [prev_ignores + regexps])
20
+ opts = @prev_silencer_options.dup
21
+ opts[:ignore] = [opts[:ignore], regexps]
22
+ _reconfigure_silencer(opts)
22
23
  end
23
24
 
24
25
  def replace_with_bang_ignores(regexps)
25
- _reconfigure_silencer(ignore!: regexps)
26
+ opts = @prev_silencer_options.dup
27
+ opts.delete(:ignore)
28
+ opts[:ignore!] = regexps
29
+ _reconfigure_silencer(opts)
26
30
  end
27
31
 
28
32
  def replace_with_only(regexps)
29
- _reconfigure_silencer(only: regexps)
33
+ opts = @prev_silencer_options.merge(only: regexps)
34
+ _reconfigure_silencer(opts)
30
35
  end
31
36
 
32
37
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Listen
4
- VERSION = '3.10.0'
4
+ VERSION = '3.10.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: listen
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.0
4
+ version: 3.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thibaud Guillaume-Gentil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-01-16 00:00:00.000000000 Z
11
+ date: 2026-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logger
@@ -117,9 +117,9 @@ metadata:
117
117
  allowed_push_host: https://rubygems.org
118
118
  bug_tracker_uri: https://github.com/guard/listen/issues
119
119
  changelog_uri: https://github.com/guard/listen/releases
120
- documentation_uri: https://www.rubydoc.info/gems/listen/3.10.0
120
+ documentation_uri: https://www.rubydoc.info/gems/listen/3.10.1
121
121
  homepage_uri: https://github.com/guard/listen
122
- source_code_uri: https://github.com/guard/listen/tree/v3.10.0
122
+ source_code_uri: https://github.com/guard/listen/tree/v3.10.1
123
123
  post_install_message:
124
124
  rdoc_options: []
125
125
  require_paths: