From 79de8e9f6ba093da4d792294f1675083634c9e3b Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 2 Apr 2019 08:08:29 +0000 Subject: downloader.rb: keep linked file newer than cached file * tool/downloader.rb (Downloader.save_cache): keep linked file newer than cached file, so that GNU make triggers when the content is updated. it uses the timestamp of symlink itself instead of the target. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- tool/downloader.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'tool') diff --git a/tool/downloader.rb b/tool/downloader.rb index 9c72856484..0386fe273b 100644 --- a/tool/downloader.rb +++ b/tool/downloader.rb @@ -285,14 +285,20 @@ class Downloader end def self.save_cache(cache, file, name) - if cache and !cache.eql?(file) and !cache.exist? + return unless cache or cache.eql?(file) + begin + st = cache.stat + rescue begin file.rename(cache) rescue - else - link_cache(cache, file, name) + return end + else + return unless st.mtime > file.lstat.mtime + file.unlink end + link_cache(cache, file, name) end def self.with_retry(max_times, &block) -- cgit v1.2.3