feature: Forced OS Cache rebuild for unit tests (#7163)

This commit is contained in:
Neil Lathwood
2017-08-16 19:58:10 +01:00
committed by Tony Murray
parent 1f98bf46a5
commit 96b010a735
2 changed files with 5 additions and 3 deletions

View File

@@ -1646,15 +1646,16 @@ function load_all_os($existing = false, $cached = true)
} }
/** /**
* Update the OS cache file cache/os_defs.cache * * Update the OS cache file cache/os_defs.cache
* @param bool $force
*/ */
function update_os_cache() function update_os_cache($force = false)
{ {
global $config; global $config;
$cache_file = $config['install_dir'] . '/cache/os_defs.cache'; $cache_file = $config['install_dir'] . '/cache/os_defs.cache';
$cache_keep_time = $config['os_def_cache_time'] - 7200; // 2hr buffer $cache_keep_time = $config['os_def_cache_time'] - 7200; // 2hr buffer
if (!is_file($cache_file) || time() - filemtime($cache_file) > $cache_keep_time) { if ($force === true || !is_file($cache_file) || time() - filemtime($cache_file) > $cache_keep_time) {
d_echo('Updating os_def.cache... '); d_echo('Updating os_def.cache... ');
load_all_os(false, false); load_all_os(false, false);
file_put_contents($cache_file, serialize($config['os'])); file_put_contents($cache_file, serialize($config['os']));

View File

@@ -47,6 +47,7 @@ chdir($install_dir);
ini_set('display_errors', 1); ini_set('display_errors', 1);
error_reporting(E_ALL & ~E_WARNING); error_reporting(E_ALL & ~E_WARNING);
update_os_cache(true); // Force update of OS Cache
load_all_os(); // pre-load OS so we don't keep loading them load_all_os(); // pre-load OS so we don't keep loading them
if (getenv('DBTEST')) { if (getenv('DBTEST')) {