Index: trunk/PS-IPP-Config/lib/PS/IPP/Config.pm
===================================================================
--- trunk/PS-IPP-Config/lib/PS/IPP/Config.pm	(revision 30316)
+++ trunk/PS-IPP-Config/lib/PS/IPP/Config.pm	(revision 30630)
@@ -1148,43 +1148,10 @@
     if ($neb->storage_object_exists($output)) {
         if ($delete_existing) {
-            # avoid dead instances by moving the file before deleting it.
-            # append current time to form new name
-            my $todelete;
-            eval {
-                # parse the key so that we can compute the new name
-                require Nebulous::Key;
-            };
-            if ($@) {
-                carp "Can't find Nebulous::Key";
-                $$r_error = $PS_EXIT_CONFIG_ERROR;
-                return undef;
-            }
-            eval {
-                # parse the key so that we can compute the new name
-                my $neb_key = Nebulous::Key::parse_neb_key($output);
-                die "parse_neb_key failed" if !$neb_key;
-                my $path = $neb_key->path;
-                die "neb_key has no path" if !$path;
-                my $ticks = time();
-                $todelete = "ipp_trash/$path.$ticks";
-                $neb->move($output, $todelete);
-            };
-            if ($@) {
-                carp "nebulous move failed for $output";
+            $$r_error = $self->_kill_nebulous_file($output);
+            if ($$r_error) {
                 $output = undef;
-                $$r_error = $PS_EXIT_SYS_ERROR;
-            }
-            if ($todelete) {
-                eval {
-                    $neb->delete($todelete);
-                };
-                if ($@) {
-                    carp "nebulous delete for $todelete failed. Ignoring.\n";
-                    $$r_error = $PS_EXIT_SYS_ERROR;
-                }
             }
         } else {
             # Make sure that there is only 1 instance.
-
             eval {
                 $neb->there_can_be_only_one($output);
@@ -1198,4 +1165,77 @@
     }
     return $output;
+}
+
+# _kill_nebulous_file: reliably get a nebulous file out of way.
+# First move it to the trash then attempt to delete it. No failure if delete fails.
+# The file is in the trash.
+# Assumes that file is a nebulous file with a storage object that exists
+# Users should call kill_file()
+# Returns 0 on success otherwise and a PS_EXIT error code on failure
+sub _kill_nebulous_file {
+    my $self = shift;
+    my $filename = shift;
+    my $neb = $self->nebulous;
+
+    # avoid dead instances by moving the file before deleting it.
+    # append current time to form new name
+    my $todelete;
+    eval {
+        # parse the key so that we can compute the new name
+        require Nebulous::Key;
+    };
+    if ($@) {
+        carp "Can't find Nebulous::Key";
+        return $PS_EXIT_CONFIG_ERROR;
+    }
+    eval {
+        # parse the key so that we can compute the new name
+        my $neb_key = Nebulous::Key::parse_neb_key($filename);
+        die "parse_neb_key failed" if !$neb_key;
+        my $path = $neb_key->path;
+        die "neb_key has no path" if !$path;
+        my $ticks = time();
+        $todelete = "ipp_trash/$path.$ticks";
+        $neb->move($filename, $todelete);
+    };
+    if ($@) {
+        carp "nebulous move failed for $filename";
+        return $PS_EXIT_SYS_ERROR;
+    }
+    if ($todelete) {
+        eval {
+            $neb->delete($todelete);
+        };
+        if ($@) {
+            carp "nebulous delete for $todelete failed. Ignoring.\n";
+            return $PS_EXIT_SYS_ERROR;
+        }
+    }
+    return 0;
+}
+
+# user level interface to kill_file reliably get a file out of way.
+#
+# If a nebulous file, move it to the trash then attempt to delete it. 
+# if non nebulous file just delete it.
+# Returns 0 on success otherwise and a PS_EXIT error code on failure
+
+sub kill_file {
+    my $self = shift;
+    my $filename = shift;
+    my $neb = $self->nebulous;
+
+    my $scheme = file_scheme($filename);
+    if (!$scheme or ($scheme ne 'neb')) {
+        if ($self->file_exists($filename)) {
+            if (!$self->file_delete($filename)) {
+                carp "failed to delete $filename";
+                return $PS_EXIT_SYS_ERROR;
+            }
+        }
+    } elsif ($neb->storage_object_exists($filename)) {
+        $self->_kill_nebulous_file($filename);
+    }
+    return 0;
 }
 
