Added symlinks to DA.
This commit is contained in:
parent
3e2340bf4b
commit
d00c40ca13
|
@ -105,7 +105,7 @@ sub list {
|
|||
$fn = quote($fn);
|
||||
$fh_out->print($fn);
|
||||
|
||||
$fh_out->print(metastr($fn, $st));
|
||||
$fh_out->print($self->metastr($fn, $st));
|
||||
|
||||
$fh_out->print("\n");
|
||||
},
|
||||
|
@ -174,7 +174,7 @@ sub get {
|
|||
$fh_out->printflush("fail $path ($!)\n");
|
||||
return;
|
||||
}
|
||||
$fh_out->print("data $path ", metastr($fn, $st), "\n");
|
||||
$fh_out->print("data $path ", $self->metastr($fn, $st), "\n");
|
||||
my $size = $st->size;
|
||||
my $err;
|
||||
my $sha1 = Digest::SHA1->new;
|
||||
|
@ -208,20 +208,20 @@ sub get {
|
|||
} elsif (typestr($st->mode) eq 'l') {
|
||||
my $target = readlink($fn);
|
||||
if (length($target) == $st->size) {
|
||||
$fh_out->print("data $path ", metastr($fn, $st), "\n");
|
||||
$fh_out->print("data $path ", $self->metastr($fn, $st), "\n");
|
||||
$fh_out->print("$target\n");
|
||||
$fh_out->print("chk sha1 ", sha1_hex($target), "\n");
|
||||
} else {
|
||||
$fh_out->print("fail ($!)\n");
|
||||
}
|
||||
} else {
|
||||
$fh_out->print("nodata $path ", metastr($fn, $st), "\n");
|
||||
$fh_out->print("nodata $path ", $self->metastr($fn, $st), "\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub metastr {
|
||||
my ($fn, $st) = @_;
|
||||
my ($self, $fn, $st) = @_;
|
||||
$st = lstat($fn) unless defined($st);
|
||||
|
||||
my $s = "";
|
||||
|
@ -251,6 +251,10 @@ sub metastr {
|
|||
$s .= " " . 'sticky=1' if $mode & 01000;
|
||||
$s .= " " . 'rdev=' . $st->rdev if ($mode & 0120000) == 0020000;
|
||||
|
||||
if (typestr($mode) eq 'l') {
|
||||
$s .= " " . 'lt=' . quote(decode($self->{charset}, readlink($fn)));
|
||||
}
|
||||
|
||||
return $s;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
use warnings;
|
||||
use strict;
|
||||
|
||||
use Test::More 'no_plan';
|
||||
use Test::More tests => 21;
|
||||
|
||||
BEGIN { use_ok( 'Simba::DA' ); }
|
||||
|
||||
|
@ -18,6 +18,7 @@ ok($list);
|
|||
cmp_ok($list, '=~', qr{^\. .* t=d }m, 'root is a directory');
|
||||
cmp_ok($list, '=~', qr{^\./test.txt .* t=f s=14 }m, 'text file found');
|
||||
cmp_ok($list, '=~', qr{^\./test.bin .* t=f s=1024 }m, 'binary file found');
|
||||
cmp_ok($list, '=~', qr{^\./test.link .* t=l .* lt=test.bin( |$)}m, 'symlink found');
|
||||
|
||||
my $result;
|
||||
open($fh, '>', \$result);
|
||||
|
|
Loading…
Reference in New Issue