diff options
-rw-r--r-- | usr/src/libpiny/Piny/Repo.pm | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/usr/src/libpiny/Piny/Repo.pm b/usr/src/libpiny/Piny/Repo.pm index b10651f..5249b61 100644 --- a/usr/src/libpiny/Piny/Repo.pm +++ b/usr/src/libpiny/Piny/Repo.pm @@ -2,6 +2,8 @@ package Piny::Repo; use Moose; +use File::Find qw( find ); + use Piny::User; # Attributes @@ -36,8 +38,9 @@ has 'repostat' => ); has 'owner' => - ( is => 'ro' + ( is => 'rw' , isa => 'Piny::User' + , trigger => \&_change_owner , lazy_build => 1 , init_arg => undef ); @@ -81,6 +84,14 @@ sub _set_description { close( $fd ) or die "Error when closing " . $s->path( ) . "/description: $!"; }; +sub _change_owner { + my ( $s, $new_owner, $old_owner ) = @_; + + return unless defined $old_owner; + + find( { wanted => sub { chown( $new_owner->uid( ), -1, $_ ) or die "Couldn't chown $_: $!"; }, no_chdir => 1 }, $s->path( ) ); +}; + # Builder methods # If constructed with just one argument, then treat it as a repo name. |