diff --git a/bioinfoconda/local/src/X-getdata.pl b/bioinfoconda/local/src/X-getdata.pl index 1a3e2c9..97310bc 100755 --- a/bioinfoconda/local/src/X-getdata.pl +++ b/bioinfoconda/local/src/X-getdata.pl @@ -15,40 +15,52 @@ # TODO: accept patterns for http too. -# TODO: check if new dest is overriding something +# TODO: accept patterns in the middle of the path. -# TODO: support file:// and scp:// protocols for local downloads +# TODO: check if new dest is overriding something. + +# TODO: pass @ARGV as @params for rsync, e.g. to specify port or +# something else in the command line. my $NAME = basename($0); my $USAGE =<&1 |"); + while (my $line = ) + { + if ($line =~ m/^\d{4}\/\d{2}\/\d{2}/) + { + chomp($line); + $line .= " " . $dest . "\n"; + my @line = split(" ", $line); + $line[2] = $source; + push @output, @line; + } + print $line; + } + + return @output; +} + +sub rsync_recursive +{ + my $source = $_[0]; + my $dest = $_[1]; + my $dirname = dirname($dest); + my @output = (); + + unless(-d $dirname or make_path($dirname)) + { + die("ERROR: cannot make path $dirname.\n"); + } + + open(RSYNCOUTPUT, "rsync -rtvz --out-format=\"%t %f\" $source $dest 2>&1 |"); + while (my $line = ) + { + if ($line =~ m/^\d{4}\/\d{2}\/\d{2}/) + { + chomp($line); + $line .= " " . $dest . "\n"; + my @line = split(" ", $line); + $line[3] = $line[3] . $line[2]; + $line[2] = dirname($source) . "/" . $line[2]; + push @output, @line; + } + print $line; + } + + return @output; +} + sub update_index { my @log = @{$_[0]}; @@ -516,7 +711,7 @@ sub fix_index # Now check if the files with the same path have actually the # same checksum - foreach $path (keys(%tree_bypath)) + foreach my $path (keys(%tree_bypath)) { if (exists($index_bypath{$path}) and $tree_bypath{$path}[3] ne $index_bypath{$path}[3]) { @@ -613,7 +808,7 @@ sub is_pseudo sub is_recursive { - my $path = $_[0]; + my $path = $_[0]; - return ($path =~ m/[\*\?\[\]\{\}]/); + return ($path =~ m/[\*\?\[\]\{\}]/); }