Skip to content

Commit

Permalink
put error response before thumbgen (#1128)
Browse files Browse the repository at this point in the history
  • Loading branch information
psilabs-dev authored Dec 24, 2024
1 parent 68a82a0 commit 67f3cb1
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions lib/LANraragi/Controller/Api/Archive.pm
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,24 @@ sub create_archive {

my ( $status_code, $id, $response_title, $message ) = LANraragi::Model::Upload::handle_incoming_file( $tempfile, $catid, $tags, $title, $summary );

unless ( $status_code == 200 ) {
$redis->del("upload:$filename");
$redis->quit();
return $self->render(
json => {
operation => "upload",
success => 0,
error => $message,
id => $id
},
status => $status_code
);
}

# post-processing thumbnail generation
my %hash = $redis->hgetall($id);
my ( $thumbhash ) = @hash{qw(thumbhash)};
unless ( length $thumbhash ) {
$logger->info("Thumbnail hash invalid, regenerating.");
my $thumbdir = LANraragi::Model::Config->get_thumbdir;
$thumbhash = "";
extract_thumbnail( $thumbdir, $id, 0, 1 );
Expand All @@ -246,18 +259,6 @@ sub create_archive {
$redis->del("upload:$filename");
$redis->quit();

unless ( $status_code == 200 ) {
return $self->render(
json => {
operation => "upload",
success => 0,
error => $message,
id => $id
},
status => $status_code
);
}

return $self->render(
json => {
operation => "upload",
Expand Down

0 comments on commit 67f3cb1

Please sign in to comment.