Advertisement
Guest User

bug

a guest
Jan 7th, 2014
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.41 KB | None | 0 0
  1. my $delay = Mojo::IOLoop->delay(sub{
  2.  
  3.     my $delay = shift;
  4.  
  5.     my @all = @_;
  6.  
  7.     my @ress = map {$all[$_]} grep {!($_ & 1)} 0..$#all; # gets rid of all odd elements
  8.  
  9.     my $atleastonefailure = 0;
  10.  
  11.     foreach my $res (@ress){
  12.      
  13.       if(!$res){ # at least one upload failed
  14.      
  15.         $atleastonefailure++;
  16.      
  17.       }
  18.       else{
  19.  
  20.         my $found = 0;
  21.  
  22.         foreach my $o (keys %{$sessimghash}){
  23.           if($sessimghash->{$o}->{cloudid} eq $res->{public_id}){
  24.             $sessimghash->{$o}->{cloudyflag} = 1;
  25.             $found = 1;
  26.             last;
  27.           }
  28.  
  29.         }
  30.  
  31.         return $self->render('minhaloja', regstatus => 'errcloudses') if(!$found);
  32.       }
  33.     }
  34.  
  35.     if($atleastonefailure){
  36.       return $self->render('minhaloja', regstatus => 'errcloudfail');
  37.     }
  38.  
  39.     # all submitted images uploaded ok and form parameters validated
  40.     return $self->render('minhaloja', regstatus => 'ok');
  41. });
  42.  
  43. foreach my $picio (1..scalar(@pics2upload)){
  44.  
  45.   my $md5 = datamd5($pics2upload[$picio-1]->slurp);
  46.  
  47.   my $pubid = $self->uuid;
  48.  
  49.   $self->pictures($picio => {md5 => $md5, cloudid => $pubid, cloudyflag => 0});
  50.  
  51.   $self->cloudinary_upload({
  52.                  file => $pics2upload[$picio-1],
  53.                  public_id => $pubid, # that's how we will recognize that image upload in on_finish()
  54.                  delay => $delay->begin,
  55.              });
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement