Prettyfied the update printout, moved directory to be a part of $filename in update and added removing of downloaded file (verbosely)

This commit is contained in:
2019-07-24 22:00:59 +02:00
parent d370ca0a0c
commit 94d6f227ca
2 changed files with 10 additions and 6 deletions

2
pcurse
View File

@ -121,7 +121,7 @@ foreach my $unpacking(keys %tounpack) {
my $file = $tounpack{$unpacking}->[1];
my $version = $tounpack{$unpacking}->[2];
if(pcurse::update($unpacking,$file,$conf->{'wowpath'})) {
say 'Updated '.$addons->[$id]->{'name'}.' from version '.$addons->[$id]->{'version'}.' to '.$version;
say 'Updated '.$addons->[$id]->{'name'}.': '.$addons->[$id]->{'version'}.' => '.$version;
$addons->[$id]->{'version'} = $version;
} else {
say 'Unpacking failed for '.$unpacking;

View File

@ -276,14 +276,18 @@ sub update {
my $filename = shift;
my $file = shift;
my $targetpath = shift;
unless(-e "/tmp/$filename") {
open my $fh, '>', "/tmp/$filename" or return 0;
$filename = '/tmp/'.$filename;
unless(-e "$filename") {
open my $fh, '>', "$filename" or return 0;
print $fh $file;
close $fh;
}
if(-e "/tmp/$filename") {
my $ae = Archive::Extract->new(archive => "/tmp/$filename");
return 1 if($ae->extract(to=>$targetpath));
if(-e "$filename") {
my $ae = Archive::Extract->new(archive => "$filename");
if($ae->extract(to=>$targetpath)) {
system("rm","-v","$filename");
return 1;
}
}
return 0;
}