diff options
author | Jon Robertson <jonrober@stanford.edu> | 2014-10-14 17:06:43 -0700 |
---|---|---|
committer | Jon Robertson <jonrober@stanford.edu> | 2014-10-27 15:48:19 -0700 |
commit | f0d6302bbc5fd477236e3c5ea2193a17ef405bba (patch) | |
tree | 96d33fac89d71d512bea389abc4272343adcbaa3 /perl/lib/Wallet/Object/File.pm | |
parent | 80004a08e0580c25965ae37f602db1970157ddfb (diff) |
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
Diffstat (limited to 'perl/lib/Wallet/Object/File.pm')
-rw-r--r-- | perl/lib/Wallet/Object/File.pm | 10 |
1 files changed, 7 insertions, 3 deletions
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; |