Skip to content

Commit a1b5cf2

Browse files
committed
Reduce redundant tarball downloads
1 parent fe91893 commit a1b5cf2

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

bin/build

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,29 @@ require 'digest/sha1'
66
require 'fileutils'
77

88
class Builder
9+
TARBALL_CACHE_EXPIRATION = 60 * 10
10+
911
def initialize(redis_branch, tmp_dir)
1012
@redis_branch = redis_branch
1113
@tmp_dir = tmp_dir
1214
@build_dir = File.join(@tmp_dir, "cache", "redis-#{redis_branch}")
1315
end
1416

1517
def run
16-
download_tarball
18+
download_tarball_if_needed
1719
if old_checkum != checksum
1820
build
1921
update_checksum
2022
end
2123
0
2224
end
2325

24-
def download_tarball
25-
command!('wget', tarball_url, '-O', tarball_path)
26+
private
27+
28+
def download_tarball_if_needed
29+
return if File.exist?(tarball_path) && File.mtime(tarball_path) > Time.now - TARBALL_CACHE_EXPIRATION
30+
31+
command!('wget', '-q', tarball_url, '-O', tarball_path)
2632
end
2733

2834
def tarball_path

makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ stop_slave:
6363
@$(call kill-redis,${SLAVE_PID_PATH})
6464

6565
start_slave: ${BINARY}
66-
${BINARY}\
66+
@${BINARY}\
6767
--daemonize yes\
6868
--pidfile ${SLAVE_PID_PATH}\
6969
--port ${SLAVE_PORT}\

0 commit comments

Comments
 (0)