From f0d6302bbc5fd477236e3c5ea2193a17ef405bba Mon Sep 17 00:00:00 2001 From: Jon Robertson Date: Tue, 14 Oct 2014 17:06:43 -0700 Subject: Added rename support for file objects File objects now support a rename command, which will rename the object and move the file to the right spot in the file store under its new name. Change-Id: I10ea2b8012586d69f0894905cfba54a738f3e418 --- perl/lib/Wallet/Object/File.pm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'perl/lib/Wallet/Object/File.pm') diff --git a/perl/lib/Wallet/Object/File.pm b/perl/lib/Wallet/Object/File.pm index 65fe40e..226e32c 100644 --- a/perl/lib/Wallet/Object/File.pm +++ b/perl/lib/Wallet/Object/File.pm @@ -81,9 +81,13 @@ sub rename { $object->ob_name ($new_name); # Update the file to the path for the new name, and die if we can't. - $self->{name} = $new_name; - my $new_path = $self->file_path; - move($old_path, $new_path) or die $!; + # If the old path isn't there, then assume we haven't yet stored and + # keep going. + if ($old_path) { + $self->{name} = $new_name; + my $new_path = $self->file_path; + move($old_path, $new_path) or die $!; + } $object->update; $guard->commit; -- cgit v1.2.3