wisest owl (wisest_owl) wrote in changelog,
wisest owl
wisest_owl
changelog

[ljcom] r9530: LJSUP-6670. can not upload userhead.

Committer: gprochaev
LJSUP-6670. can not upload userhead.

U   trunk/cgi-bin/LJ/FileStore.pm
U   trunk/cgi-bin/LJ/UserHead.pm
U   trunk/htdocs/admin/userheads/manage.bml
Modified: trunk/cgi-bin/LJ/FileStore.pm
===================================================================
--- trunk/cgi-bin/LJ/FileStore.pm	2010-09-22 07:55:29 UTC (rev 9529)
+++ trunk/cgi-bin/LJ/FileStore.pm	2010-09-22 08:02:38 UTC (rev 9530)
@@ -11,10 +11,12 @@
     my %args = @_;
 
     my $result = ();
-    $result = LJ::MogileFS::Frontend->save_file(
+    $result = eval {LJ::MogileFS::Frontend->save_file(
         content => $args{content},
         fs_key  => $args{path},
-    ) if $args{content};
+    )} if $args{content};
+
+    return undef if $@;
     
     return undef unless $result;
 

Modified: trunk/cgi-bin/LJ/UserHead.pm
===================================================================
--- trunk/cgi-bin/LJ/UserHead.pm	2010-09-22 07:55:29 UTC (rev 9529)
+++ trunk/cgi-bin/LJ/UserHead.pm	2010-09-22 08:02:38 UTC (rev 9530)
@@ -13,6 +13,14 @@
     return bless $args, $class;
 }
 
+sub delete {
+    my $self = shift;
+
+    my $dbh = LJ::get_db_writer();
+
+    my $res = $dbh->do ("DELETE FROM shop_userheads WHERE uh_id = ?", undef, $self->get_uh_id);
+}
+
 sub set_enabled {
     my $self = shift;
 

Modified: trunk/htdocs/admin/userheads/manage.bml
===================================================================
--- trunk/htdocs/admin/userheads/manage.bml	2010-09-22 07:55:29 UTC (rev 9529)
+++ trunk/htdocs/admin/userheads/manage.bml	2010-09-22 08:02:38 UTC (rev 9530)
@@ -13,6 +13,8 @@
 return "<b>Error:</b> no access"
     unless $LJ::IS_DEV_SERVER || LJ::check_priv($remote, "admin", "userheads");
 
+my $save_error = '';
+
 if ($FORM{'upload'}) {
     my $error = '';
     #BML::parse_multipart(\%POST, \$error, 999992048);
@@ -32,6 +34,11 @@
         $mime_type = format_magic($magic)
             or die "Unknown format for upload";
         my $result = LJ::FileStore->save_file(path => "/userhead/" . $uh->get_uh_id, content => $userhead_content, mime_type => $mime_type, content_length => $content_length);
+        unless ($result) {
+            warn "/userhead/" . $uh->get_uh_id . " was not been saved";
+            $save_error = 'when adding userhead error occurred. please, please try again.';
+            $uh->delete;
+        }
     }
 }
 
@@ -71,6 +78,8 @@
 
 my $dbh = LJ::get_db_writer();
 
+    $ret .= "<font color=\"red\"><b>".$save_error."</b></font>" if $save_error;
+
     $ret .= <<FORM;
     <form method="post" enctype="multipart/form-data">
     <table>

Tags: bml, ljcom, pm, wisest-owl
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments