Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pve-manager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
pve-manager
Commits
56e85d00
Commit
56e85d00
authored
Aug 02, 2013
by
Dietmar Maurer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apt: try to send updated packe list only once
parent
a2e0742b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
10 deletions
+33
-10
APT.pm
PVE/API2/APT.pm
+33
-10
No files found.
PVE/API2/APT.pm
View file @
56e85d00
...
@@ -144,10 +144,28 @@ my $assemble_pkginfo = sub {
...
@@ -144,10 +144,28 @@ my $assemble_pkginfo = sub {
# we try to cache results
# we try to cache results
my
$pve_pkgstatus_fn
=
"
/var/lib/pve-manager/pkgupdates
";
my
$pve_pkgstatus_fn
=
"
/var/lib/pve-manager/pkgupdates
";
my
$read_cached_pkgstatus
=
sub
{
my
$data
=
[]
;
eval
{
my
$jsonstr
=
PVE::Tools::
file_get_contents
(
$pve_pkgstatus_fn
,
5
*
1024
*
1024
);
$data
=
decode_json
(
$jsonstr
);
};
if
(
my
$err
=
$@
)
{
warn
"
error reading cached package status in
$pve_pkgstatus_fn
\n
";
}
return
$data
;
};
my
$update_pve_pkgstatus
=
sub
{
my
$update_pve_pkgstatus
=
sub
{
syslog
('
info
',
"
update new package list:
$pve_pkgstatus_fn
");
syslog
('
info
',
"
update new package list:
$pve_pkgstatus_fn
");
my
$notify_status
=
{};
my
$oldpkglist
=
&
$read_cached_pkgstatus
();
foreach
my
$pi
(
@$oldpkglist
)
{
$notify_status
->
{
$pi
->
{
Package
}}
=
$pi
->
{
Version
};
}
my
$pkglist
=
[]
;
my
$pkglist
=
[]
;
my
$cache
=
&
$get_apt_cache
();
my
$cache
=
&
$get_apt_cache
();
...
@@ -194,6 +212,14 @@ my $update_pve_pkgstatus = sub {
...
@@ -194,6 +212,14 @@ my $update_pve_pkgstatus = sub {
}
}
}
}
}
}
# keep notification status (avoid sending mails abou new packages more than once)
foreach
my
$pi
(
@$pkglist
)
{
if
(
my
$ns
=
$notify_status
->
{
$pi
->
{
Package
}})
{
$pi
->
{
NotifyStatus
}
=
$ns
if
$ns
eq
$pi
->
{
Version
};
}
}
PVE::Tools::
file_set_contents
(
$pve_pkgstatus_fn
,
encode_json
(
$pkglist
));
PVE::Tools::
file_set_contents
(
$pve_pkgstatus_fn
,
encode_json
(
$pkglist
));
return
$pkglist
;
return
$pkglist
;
...
@@ -230,15 +256,7 @@ __PACKAGE__->register_method({
...
@@ -230,15 +256,7 @@ __PACKAGE__->register_method({
my
$st3
=
File::stat::
stat
("
/var/lib/dpkg/status
");
my
$st3
=
File::stat::
stat
("
/var/lib/dpkg/status
");
if
(
$st2
&&
$st3
&&
$st2
->
mtime
<=
$st1
->
mtime
&&
$st3
->
mtime
<=
$st1
->
mtime
)
{
if
(
$st2
&&
$st3
&&
$st2
->
mtime
<=
$st1
->
mtime
&&
$st3
->
mtime
<=
$st1
->
mtime
)
{
my
$data
;
if
(
my
$data
=
&
$read_cached_pkgstatus
())
{
eval
{
my
$jsonstr
=
PVE::Tools::
file_get_contents
(
$pve_pkgstatus_fn
,
5
*
1024
*
1024
);
$data
=
decode_json
(
$jsonstr
);
};
if
(
my
$err
=
$@
)
{
warn
"
error readin cached package status in
$pve_pkgstatus_fn
\n
";
# continue and overwrite cache with new content
}
else
{
return
$data
;
return
$data
;
}
}
}
}
...
@@ -344,7 +362,12 @@ __PACKAGE__->register_method({
...
@@ -344,7 +362,12 @@ __PACKAGE__->register_method({
print
$fh
$data
;
print
$fh
$data
;
$fh
->
close
();
$fh
->
close
()
||
die
"
unable to close 'sendmail' - $!
";
foreach
my
$pi
(
@$pkglist
)
{
$pi
->
{
NotifyStatus
}
=
$pi
->
{
Version
};
}
PVE::Tools::
file_set_contents
(
$pve_pkgstatus_fn
,
encode_json
(
$pkglist
));
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment