make directory first, needed for lock file
This commit is contained in:
parent
190e6c788a
commit
c6fadf8200
@ -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";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user