From dd1186fba508abf690f4d2dd4692081aa4272c95 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 26 Apr 2014 03:16:06 +0000 Subject: [PATCH] ssoma: lock against concurrent fetch/remote add A user may manually run ssoma while cron is running, so avoid any potential synchronization problems in this case. --- ssoma | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ssoma b/ssoma index ef99a00..9f71aa3 100755 --- a/ssoma +++ b/ssoma @@ -178,8 +178,10 @@ sub cmd_add { x(qw/git config/, "target.$target.$cfg", $path); } - $git->tmp_git_do(sub { - x(qw/git remote add --mirror=fetch origin/, $url); + $git->sync_do(sub { + $git->tmp_git_do(sub { + x(qw/git remote add --mirror=fetch origin/, $url); + }); }); } @@ -245,11 +247,13 @@ sub do_sync { @$targets = keys %t; } - $git->tmp_git_do(sub { - my @cmd = qw/git fetch/; - push @cmd, '-q' if $opts{quiet}; - push @cmd, '-f' if $opts{force}; - x(@cmd); + $git->sync_do(sub { + $git->tmp_git_do(sub { + my @cmd = qw/git fetch/; + push @cmd, '-q' if $opts{quiet}; + push @cmd, '-f' if $opts{force}; + x(@cmd); + }); }); foreach my $target (@$targets) { -- 2.26.2