Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/rake/file_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@ class FileTask < Task
# Is this file task needed? Yes if it doesn't exist, or if its time stamp
# is out of date.
def needed?
!File.exist?(name) || out_of_date?(timestamp) || @application.options.build_all
begin
out_of_date?(File.mtime(name)) || @application.options.build_all
Copy link
Contributor Author

@da2x da2x Sep 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling File.mtime here directly instead of timestamp because checking to see if it returned Rake::LATE was significantly slower. This is functionally the same as before as out_of_date? would never receive Rake::LATE except if there was a race condition between the first and second File.exist checks.

rescue Errno::ENOENT
true
end
end

# Time stamp for file task.
def timestamp
if File.exist?(name)
File.mtime(name.to_s)
else
begin
File.mtime(name)
rescue Errno::ENOENT
Rake::LATE
end
end
Expand Down