mirror of
https://github.com/webmin/webmin.git
synced 2025-07-21 23:40:34 +00:00
Don't try to yum list if locked
This commit is contained in:
@ -60,7 +60,9 @@ else {
|
||||
sub list_available
|
||||
{
|
||||
local ($nocache) = @_;
|
||||
if ($nocache || &cache_expired($available_cache_file)) {
|
||||
local $expired = &cache_expired($available_cache_file);
|
||||
if ($nocache || $expired == 2 ||
|
||||
$expired == 1 && !&check_available_lock()) {
|
||||
# Get from update system
|
||||
local @rv;
|
||||
local @avail = &packages_available();
|
||||
@ -88,6 +90,16 @@ else {
|
||||
}
|
||||
}
|
||||
|
||||
# check_available_lock()
|
||||
# Returns 1 if the package update system is currently locked
|
||||
sub check_available_lock
|
||||
{
|
||||
if ($software::update_system eq "yum") {
|
||||
return &check_pid_file("/var/run/yum.pid");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
# filter_duplicates(&packages)
|
||||
# Given a list of package structures, orders them by name and version number,
|
||||
# and removes dupes with the same name
|
||||
@ -100,16 +112,19 @@ local %done;
|
||||
return grep { !$done{$_->{'name'},$_->{'system'}}++ } @rv;
|
||||
}
|
||||
|
||||
sub cache_expired
|
||||
# cache_expired(file)
|
||||
# Checks if some cache has expired. Returns 0 if OK, 1 if expired, 2 if
|
||||
# totally missing.
|
||||
sub cache_expired
|
||||
{
|
||||
local ($file) = @_;
|
||||
local @st = stat($file);
|
||||
if (!@st || !$config{'cache_time'} ||
|
||||
time()-$st[9] > $config{'cache_time'}*60*60) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 2 if (!@st);
|
||||
if (!$config{'cache_time'} || time()-$st[9] > $config{'cache_time'}*60*60) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub write_cache_file
|
||||
{
|
||||
|
Reference in New Issue
Block a user