chown md5pool to md5 user for last copy to correct quota usage
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 8 Oct 2011 22:00:52 +0000 (00:00 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 8 Oct 2011 22:12:51 +0000 (00:12 +0200)
lib/CloudStore/Store.pm

index f49785b..57addea 100644 (file)
@@ -54,6 +54,22 @@ sub new_file {
 sub remove_file {
        my ( $self, $data ) = @_;
 #      $self->usage_decr( $data );
+
+       my $md5sum = $self->md5sum($data);
+       if ( ! exists $md5sum->{ $data->{file} } ) {
+               warn "ERROR: no md5 for ",dump $data;
+               return;
+       }
+       my $md5 = $md5sum->{ $data->{file} };
+       my $path = $self->{md5pool} . '/' . $md5;
+       my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
+               $atime,$mtime,$ctime,$blksize,$blocks)
+                       = stat($path);
+       if ( $nlink == 1 ) {
+               my $id = getpwnam 'md5';
+               chown $id,$gid, $path;
+               warn "# chown $id $gid $path";
+       }
 }
 
 sub make_dir {