diff options
author | Julian Blake Kongslie <jblake@omgwallhack.org> | 2010-03-17 23:11:50 -0700 |
---|---|---|
committer | Julian Blake Kongslie <jblake@omgwallhack.org> | 2010-03-17 23:11:50 -0700 |
commit | 9e89415138296e0e0bb54247bd8d6f446a604457 (patch) | |
tree | d649a46365f93646da4947bf6c42ad5958e9c31b /usr | |
parent | 45a2c59b915b0019304ce6f8c297aa1bb98fa9ba (diff) | |
download | piny-code-9e89415138296e0e0bb54247bd8d6f446a604457.tar.gz piny-code-9e89415138296e0e0bb54247bd8d6f446a604457.zip |
Handle changing owner.
Diffstat (limited to 'usr')
-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. |