Skip to content

Commit

Permalink
Delete archive error handling (#886)
Browse files Browse the repository at this point in the history
* Fix delete archive error toast not appearing due to type fuckery

* Check if archive file is actually deleted

* Update lib/LANraragi/Utils/Database.pm

---------

Co-authored-by: Difegue <[email protected]>
  • Loading branch information
siliconfeces and Difegue authored Nov 1, 2023
1 parent 53ab3fb commit cb4d1f9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/LANraragi/Utils/Database.pm
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ sub delete_archive ($id) {
update_indexes( $id, $oldtags, "" );

if ( -e $filename ) {
unlink $filename;
my $status = unlink $filename;

my $thumbdir = LANraragi::Model::Config->get_thumbdir;
my $subfolder = substr( $id, 0, 2 );
Expand All @@ -248,7 +248,7 @@ sub delete_archive ($id) {
# Delete the thumbpages folder
remove_tree("$thumbdir/$subfolder/$id/");

return $filename;
return $status ? $filename : "0";
}

return "0";
Expand Down
2 changes: 1 addition & 1 deletion public/js/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ Server.deleteArchive = function (arcId, callback) {
fetch(`/api/archives/${arcId}`, { method: "DELETE" })
.then((response) => (response.ok ? response.json() : { success: 0, error: "Response was not OK" }))
.then((data) => {
if (data.success === "0") {
if (!data.success) {
LRR.toast({
heading: "Couldn't delete archive file. <br> (Maybe it has already been deleted beforehand?)",
text: "Archive metadata has been deleted properly. <br> Please delete the file manually before returning to Library View.",
Expand Down

0 comments on commit cb4d1f9

Please sign in to comment.