fix DELETED and test it
authorDobrica Pavlinusic <dpavlin@rsync1>
Thu, 17 Nov 2011 20:45:30 +0000 (21:45 +0100)
committerDobrica Pavlinusic <dpavlin@rsync1>
Thu, 17 Nov 2011 20:45:30 +0000 (21:45 +0100)
lib/CloudStore/Store.pm
test.sh

index 076cc12..2e27727 100644 (file)
@@ -87,11 +87,13 @@ sub modify_file {
                        s/[\n\r]+$//;
 
                        if ( m/^DELETED\#(.+)$/ ) {
-                               my $path = $from_dir . $1;
+                               my $path = $self->blob_path($data => $from_dir . $1 );
                                if ( -e $path ) {
-                                       unlink $path && warn "unlink $path\n";
+                                       warn "UNLINK $path";
+                                       unlink $path || warn "ERROR: unlink $path $!";
+                                       next;
                                } else {
-                                       warn "MISSING $path to unlink\n";
+                                       warn "MISSING $path to unlink";
                                        next;
                                }
                        } elsif ( ! /^(MOVED|RENAMED)\#/ ) {
@@ -282,9 +284,9 @@ warn dump $self;
 }
 
 sub blob_path {
-       my ( $self, $data ) = @_;
+       my ( $self, $data, $path ) = @_;
        my $blob = $self->{pid}->{ $data->{pid} }->{dir} || die "no dir for $data->{pid} in ",dump( $self->{pid} );
-       $blob .= '/' . $data->{file};
+       $blob .= '/' . ( defined $path ? $path : $data->{file} );
        return $blob;
 }
 
diff --git a/test.sh b/test.sh
index b0c781b..06d051b 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -102,17 +102,22 @@ push send dir1 dir2 .sync -rv
 mkdir /tmp/test/$RSYNC_LOGIN2
 RSYNC_PASSWORD=secret rsync -rv rsync://$RSYNC_LOGIN2@127.0.0.1:6501/$RSYNC_LOGIN2/received/ /tmp/test/$RSYNC_LOGIN2
 
+fi # skip tests
 
 # test file move
 
-pending=/tmp/pending.0610201109464117
-grep ^MOVED $pending | cut -d\# -f2 | xargs -i sh -c "ps ax > {}"
-push . -rv
+ps ax > Jellyfish.jpg
+push Jellyfish.jpg
 
 mkdir -p .sync/pending
-cp $pending .sync/pending/
+cat << __pending__ > .sync/pending/test
+MOVED#Jellyfish.jpg#Photos/Jellyfish.jpg
+DELETED#Photos/Jellyfish.jpg
+__pending__
+
 push .sync -rv
 
+exit
 
 ps ax > perms-test
 chmod 400 perms-test
@@ -120,11 +125,8 @@ push -va perms-test
 
 sudo sh -xc "ls -al ~$RSYNC_LOGIN/localhost/"
 
-pull
 
 
-fi # skip tests
-
 
 find $SLICE/2001/ -type f | grep -v '/\.' | xargs md5sum | sort > /tmp/test/1
 FULL=1 $base_dir/user-md5sum.pl u2001 | sort > /tmp/test/2