Skip to content

Commit

Permalink
Show syscall error message if file move failed (#990)
Browse files Browse the repository at this point in the history
* Show syscall error message if file move failed

* Check for failure during move syscall after upload
  • Loading branch information
siliconfeces authored Jun 19, 2024
1 parent 65045d3 commit d708f63
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/LANraragi/Model/Upload.pm
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,13 @@ 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" );
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 );
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?
unless ( -e $output_file ) {
return ( 0, $id, $name, "The file couldn't be moved to your content folder!" );
}
Expand Down

0 comments on commit d708f63

Please sign in to comment.