$self->delete( $t, $t_path ) if -e $t_full;
- my $ok = link $f_full, $t_full;
- $self->append( $t, 'recv', -s $t_full, $f->{uid}, $t_path );
-
- $ok = -s $t_full if $ok; # replace true with file size
-
+ my $size = -s $f_full;
my $md5;
- if ( $f->{uid} == $self->{md5}->{uid} ) {
- $md5 = $f_path; # we don't have local md5sum db for md5 user!
+
+ my $ok;
+ {
+ no autodie qw(link);
+ $ok = link $f_full, $t_full
+ };
+ if ( ! $ok || $! =~ m/cross-link/ ) {
+ $ok = symlink $f_full, $t_full;
} else {
- $md5 = $self->md5_get($f_full);
- }
- if ( ! $md5 ) {
- warn "ERROR: no md5 for $f_path";
- return $ok;
+ $size = -s $t_full;
+
+ if ( $f->{uid} == $self->{md5}->{uid} ) {
+ $md5 = $f_path; # we don't have local md5sum db for md5 user!
+ } else {
+ $md5 = $self->md5_get($f_full);
+ }
+
}
- $self->append_meta('md5sum', $t, $md5 => $t_path ); # md5sum for received files!
+ if ( $ok ) {
+ $self->append( $t, 'recv', $size, $f->{uid}, $t_path );
+ $self->append_meta('md5sum', $t, $md5 => $t_path ) if $md5; # md5sum for received files! FIXME -- cross-slice md5
+ }
- return $ok;
+ return $size;
}
sub rename_file {
use strict;
use warnings;
-use Test::More tests => 26;
+use Test::More tests => 27;
use Data::Dump qw(dump);
use lib 'lib';
usage $uid;
usage $uid2;
+ok $o->send_file( $uid2 => 'dir1/dir2/bar.txt', 2004 => 'bar.txt' ), 'send_file cross-slice';
+
ok $o->delete( $uid, 'foo.txt' );
usage $uid;