Skip to content

Commit 55151cc

Browse files
committed
Skip scan if file does not exist
- Skip caching timestamps for symbolic links by checking if `File.exists?(file)`. This resolves exception: `Unable to get stat for './src/my_file.cr': No such file or directory (Errno)` - Update API documentation with `ignore` reference
1 parent 3f3a377 commit 55151cc

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

CRYSTAL_API.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ process_runner = Sentry::ProcessRunner.new(
6060
build_args: [], # Array of String
6161
run_args: [], # Array of String
6262
should_build: true, # Bool
63-
files: [] # Array of String
63+
files: [], # Array of String
64+
ignore_regexes: [] # Array of String
6465
)
65-
```
66+
```

src/sentry.cr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,12 @@ module Sentry
200200
File.stat(file).mtime.to_s("%Y%m%d%H%M%S")
201201
end
202202

203+
private def ignored?(file : String)
204+
@ignore_regexes.any? do |regex|
205+
regex === file || regex === file.split("/").last
206+
end
207+
end
208+
203209
# Compiles and starts the application
204210
#
205211
def start_app
@@ -221,7 +227,7 @@ module Sentry
221227
app_process = @app_process
222228
files = @files
223229
Dir.glob(files) do |file|
224-
next if @ignore_regexes.any? { |r| r === file || r === file.split("/").last }
230+
next if !File.exists?(file) || ignored?(file)
225231
timestamp = get_timestamp(file)
226232
if FILE_TIMESTAMPS[file]? && FILE_TIMESTAMPS[file] != timestamp
227233
FILE_TIMESTAMPS[file] = timestamp

0 commit comments

Comments
 (0)