Merge pull request #238 from lnussel/master

make directory first, needed for lock file
This commit is contained in:
Stephan Kulow 2014-09-11 10:54:35 +02:00
commit 4b23a0b08b

View File

@ -12,6 +12,7 @@ use BSRPC ':https';
use BSXML; use BSXML;
use BSHTTP; use BSHTTP;
use Fcntl qw/:flock/; use Fcntl qw/:flock/;
use File::Path qw/make_path/;
use strict; use strict;
@ -35,6 +36,10 @@ die("uasge: bs_mirrorfull url dir\n") unless @ARGV == 2;
my ($url, $dir) = @ARGV; my ($url, $dir) = @ARGV;
$url =~ s/\/$//; $url =~ s/\/$//;
unless (-d $dir) {
make_path($dir);
}
open(my $fh, '>', $dir.'/.lock') or die "failed to open lock file: $!\n"; open(my $fh, '>', $dir.'/.lock') or die "failed to open lock file: $!\n";
unless(flock($fh, LOCK_EX|LOCK_NB)) { unless(flock($fh, LOCK_EX|LOCK_NB)) {
print "$dir is locked, waiting ...\n"; print "$dir is locked, waiting ...\n";