Added saving of updatelog

This commit is contained in:
2019-08-24 15:29:39 +02:00
parent c0010b0970
commit 9bf8c2bc5e
2 changed files with 19 additions and 3 deletions

4
pcurse
View File

@@ -124,6 +124,10 @@ foreach my $unpacking(keys %tounpack) {
if(pcurse::update($unpacking,$file,$conf->{'wowpath'})) {
say 'Updated '.$addons->[$id]->{'name'}.': '.$addons->[$id]->{'version'}.' => '.$version;
$addons->[$id]->{'version'} = $version;
my $ret = pcurse::updatelog($addons->[$id]->{'name'},$addons->[$id]->{'version'},$version);
if($ret->{'retval'} == 0) {
push(@errors, $ret->{'message'});
}
} else {
say 'Unpacking failed for '.$unpacking;
}

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env perl
package pcurse;
use strict;
no warnings 'all';
use DateTime;
use IO::Socket::SSL;
use Getopt::Long;
use Archive::Extract;
@@ -348,4 +348,16 @@ sub init_pool {
return $p;
}
sub updatelog {
my $now = DateTime->now->iso8601();
my $addon_name = shift;
my $addon_oldv = shift;
my $addon_newv = shift;
my $filename = $ENV{'HOME'}.'/.pcurse/update.log';
open my $fh, '>>', $filename, or return { retval => 0, message => 'Could not open '.$filename.' for appending' };
print $fh $now.': '.$addon_name.': '.$addon_oldv.' => '.$addon_newv."\n";
close $fh;
return { retval => 1 }
}
1;