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:
14
pcurse.pm
14
pcurse.pm
@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user