aboutsummaryrefslogtreecommitdiffstats
path: root/build_vcs_cache.pl
diff options
context:
space:
mode:
authorSteve McIntyre <steve@einval.com>2018-06-06 00:47:49 +0100
committerSteve McIntyre <steve@einval.com>2018-06-06 00:47:49 +0100
commitf035d5bf50874ad2e3c2b25aefcac111b4c5cbb0 (patch)
treea2e9875fb55146d4a10e9b536a5a43a0e1374144 /build_vcs_cache.pl
parentc9d8b4e7e2e64fbbe93546bcd7454a73c559235b (diff)
Move locking into the cache build utility
Stop having multiple copies of it all calling git in parallel
Diffstat (limited to 'build_vcs_cache.pl')
-rwxr-xr-xbuild_vcs_cache.pl20
1 files changed, 16 insertions, 4 deletions
diff --git a/build_vcs_cache.pl b/build_vcs_cache.pl
index e4fe0d5c13b..220e3c7591a 100755
--- a/build_vcs_cache.pl
+++ b/build_vcs_cache.pl
@@ -14,10 +14,22 @@ use strict;
# These modules reside under webwml/Perl
use lib ($0 =~ m|(.*)/|, $1 or ".") ."/Perl";
use Local::VCS;
+use Fcntl qw/:flock/;
my $VCS = Local::VCS->new();
-print "Initialising VCS cache for performance\n";
-$VCS->cache_repo();
-$VCS->save_cache_to_database();
-print " ... done\n";
+my $topdir = $VCS->get_topdir();
+chdir ($topdir);
+
+my $cache_lock = ".git-revs-cache.lock";
+open (my $lock, "+> $cache_lock") or die "Can't create lock file $cache_lock: $!\n";
+
+flock ($lock, LOCK_EX);
+if (!$VCS->db_cache_valid()) {
+ print "Initialising VCS cache for performance\n";
+
+ $VCS->cache_repo();
+ $VCS->save_cache_to_database();
+ print " ... done\n";
+}
+flock ($lock, LOCK_UN);

© 2014-2024 Faster IT GmbH | imprint | privacy policy