Index: /trunk/Nebulous-Server/Changes
===================================================================
--- /trunk/Nebulous-Server/Changes	(revision 24994)
+++ /trunk/Nebulous-Server/Changes	(revision 24995)
@@ -36,4 +36,5 @@
       instance and just those that are available
     - add Nebulous::Server->prune_object() API
+    - don't replicate to the volume being implied by the key being replicated!
       
 0.16
Index: /trunk/Nebulous-Server/lib/Nebulous/Server.pm
===================================================================
--- /trunk/Nebulous-Server/lib/Nebulous/Server.pm	(revision 24994)
+++ /trunk/Nebulous-Server/lib/Nebulous/Server.pm	(revision 24995)
@@ -696,5 +696,5 @@
     $log->debug("entered - @_");
 
-    my ($key, $vol_name) = validate_pos(@_,
+    my ($key, $dest_vol_name) = validate_pos(@_,
         {
             type        => SCALAR,
@@ -726,28 +726,35 @@
     # instance on it.  If all avilable volume already have an instance on them
     # then we should throw an error 
-
-    # vol_name overrides the key implied volume
-    eval {
-        $key = parse_neb_key($key, $vol_name);
+    # volume names implied as part of the key are *IGNORED* as the source and
+    # *SHOULD NOT* be used as the destination either
+
+    eval {
+        $key = parse_neb_key($key);
     };
     $log->logdie("$@") if $@;
-    $vol_name = $key->volume;
 
     my $db  = $self->db($key);
 
-    if (defined $vol_name
+    # puke if the source volume is bogus, we may want to actually use this as
+    # the instance to be copied later
+    if (defined $key->volume
         and not $self->_is_valid_volume_name($key, $key->volume)) {
         unless ($key->hard_volume) {
-            $log->warn( "$vol_name is not a known volume name" );
-            $vol_name = undef;
+            $log->warn($key->volume . " not a known volume name");
         } else {
-           $log->logdie("$vol_name is not a valid volume name");
-        }
+           $log->logdie("$key is not a valid volume name");
+        }
+    }
+    # puke if the source volume is bogus, we may want to actually use this as
+    # the instance to be copied later
+    if (defined $dest_vol_name
+        and not $self->_is_valid_volume_name($key, $dest_vol_name)) {
+           $log->logdie($key->volume . " is not a valid volume name");
     }
         
     my ($vol_id, $vol_host, $vol_path, $vol_xattr);
-    if (defined $vol_name) {
+    if (defined $dest_vol_name) {
         ($vol_id, $vol_host, $vol_path, $vol_xattr)
-            = $self->_get_storage_volume($key, $vol_name);
+            = $self->_get_storage_volume($key, $dest_vol_name);
     } else {
         ($vol_id, $vol_host, $vol_path, $vol_xattr)
@@ -810,5 +817,5 @@
             $db->rollback;
             # handle soft volumes
-            if (defined $vol_name and not defined $key->hard_volume) {
+            if (defined $dest_vol_name and not defined $key->hard_volume) {
                 $log->debug("retrying with 'any' volume");
                 return $self->replicate_object($key->path, 'any');
Index: /trunk/Nebulous-Server/t/05_server_replicate_object.t
===================================================================
--- /trunk/Nebulous-Server/t/05_server_replicate_object.t	(revision 24994)
+++ /trunk/Nebulous-Server/t/05_server_replicate_object.t	(revision 24995)
@@ -8,5 +8,5 @@
 use warnings FATAL => qw( all );
 
-use Test::More tests => 26;
+use Test::More tests => 25;
 
 use lib qw( ./t ./lib );
Index: /trunk/Nebulous-Server/t/09_server_delete_instance.t
===================================================================
--- /trunk/Nebulous-Server/t/09_server_delete_instance.t	(revision 24994)
+++ /trunk/Nebulous-Server/t/09_server_delete_instance.t	(revision 24995)
@@ -58,5 +58,5 @@
     my $key = "foo";
     my $uri1 = $neb->create_object($key, 'node01');
-    my $uri2 = $neb->replicate_object($key, 'node2');
+    my $uri2 = $neb->replicate_object($key, 'node02');
 
     # make one of the instances unavailable
