--- /dev/null
+#!/bin/sh
+
+while read path ; do
+ if [ -e $path/.meta/files ] ; then
+ cat $path/.meta/files
+ else
+ find -L $path -printf "%y %s %p\n" | tee $path/.meta/files
+ fi
+done
. /srv/cloudstore/init.d/_start_stop
BACKGROUND=0
-DAEMON="/usr/bin/stunnel -d 213.186.16.27:443 -r 6501 -P /tmp/$NAME.pid -o /tmp/$NAME.log -p /etc/ssl/rsync1.maxxo.com.pem"
+DAEMON="/usr/bin/stunnel -d 91.233.36.2:443 -r 6501 -P /tmp/$NAME.pid -o /tmp/$NAME.log -p /etc/ssl/rsync1.maxxo.com.pem"
_start_stop $*
$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 => 25;
+use Test::More tests => 26;
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;
use strict;
use warnings;
-use Test::More tests => 15;
+use Test::More tests => 19;
use Data::Dump qw(dump);
use lib 'lib';
sub gearman {
my ( $function, $args ) = @_;
- ok my $o = CloudStore::Gearman->gearman_do( @_ ), $_[0];
+ ok my $o = CloudStore::Gearman->gearman_do( @_ ), join(' ',@_);
diag dump $o;
return $o;
}
gearman( file_size => '~u2001/foo.txt' ), '==',
gearman( file_size => '~u2002/baz.txt' ), 'size_same';
+diag "test symlink to other shard";
+gearman send_file => '~u2001/foo.txt#~u2004/foo.txt';
+my $size_1 = gearman( file_size => '~u2001/foo.txt' );
+my $size_2 = gearman( file_size => '~u2004/foo.txt' );
+
+cmp_ok $size_1, '==', $size_2, 'symlink size same';
+
gearman delete => '~u2002/baz.txt';
ok ! CloudStore::Gearman->gearman_do( file_size => '~u2002/baz.txt' ), 'deleted file size';