Skip to content

Commit

Permalink
Add logging to debug occasional filetype failures on mass downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
Difegue committed Nov 4, 2024
1 parent aa1b7a1 commit 908d335
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/LANraragi/Model/Upload.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ use File::Find qw(find);
use File::Copy qw(move);

use LANraragi::Utils::Database qw(invalidate_cache compute_id);
use LANraragi::Utils::Logging qw(get_logger);
use LANraragi::Utils::Logging qw(get_logger);
use LANraragi::Utils::Database qw(redis_encode);
use LANraragi::Utils::Generic qw(is_archive get_bytelength);
use LANraragi::Utils::String qw(trim trim_CRLF trim_url);
use LANraragi::Utils::Generic qw(is_archive get_bytelength);
use LANraragi::Utils::String qw(trim trim_CRLF trim_url);

use LANraragi::Model::Config;
use LANraragi::Model::Plugins;
Expand All @@ -39,12 +39,13 @@ sub handle_incoming_file {

# Check if file is an archive
unless ( is_archive($filename) ) {
$logger->debug("$filename is not an archive, halting upload process.");
return ( 0, "deadbeef", $filename, "Unsupported File Extension ($filename)" );
}

# Compute an ID here
my $id = compute_id($tempfile);
$logger->debug("ID of uploaded file is $id");
$logger->debug("ID of uploaded file $filename is $id");

# Future home of the file
my $userdir = LANraragi::Model::Config->get_userdir;
Expand Down Expand Up @@ -110,10 +111,12 @@ sub handle_incoming_file {

# Move the file to the content folder.
# Move to a .upload first in case copy to the content folder takes a while...
move( $tempfile, $output_file . ".upload" ) or return ( 0, $id, $name, "The file couldn't be moved to your content folder: $!" );
move( $tempfile, $output_file . ".upload" )
or return ( 0, $id, $name, "The file couldn't be moved to your content folder: $!" );

# Then rename inside the content folder itself to proc Shinobu.
move( $output_file . ".upload", $output_file ) or return ( 0, $id, $name, "The file couldn't be renamed in your content folder: $!" );
move( $output_file . ".upload", $output_file )
or return ( 0, $id, $name, "The file couldn't be renamed in your content folder: $!" );

# If the move didn't signal an error, but still doesn't exist, something is quite spooky indeed!
# Really funky permissions that prevents viewing folder contents?
Expand Down

0 comments on commit 908d335

Please sign in to comment.