Pathname rawpath = rawcache_path_for_repoinfo( _pimpl->options, info );
filesystem::assert_dir(rawpath);
oldstatus = metadataStatus(info);
-
+
+ // now we've got the old (cached) status, we can decide repo.refresh.delay
+ if (policy != RefreshForced)
+ {
+ // difference in seconds
+ double diff = difftime(
+ (Date::ValueType)Date::now(),
+ (Date::ValueType)oldstatus.timestamp()) / 60;
+
+ DBG << "oldstatus: " << (Date::ValueType)oldstatus.timestamp() << endl;
+ DBG << "current time: " << (Date::ValueType)Date::now() << endl;
+ DBG << "last refresh = " << diff << " minutes ago" << endl;
+
+ if (diff < ZConfig::instance().repo_refresh_delay())
+ {
+ MIL << "Repository '" << info.alias()
+ << "' has been refreshed less than repo.refresh.delay ("
+ << ZConfig::instance().repo_refresh_delay()
+ << ") minutes ago. Advising to skip refresh" << endl;
+ return false;
+ }
+ }
+
// create temp dir as sibling of rawpath
filesystem::TmpDir tmpdir( filesystem::TmpDir::makeSibling( rawpath ) );
{
public:
Impl()
- : repo_add_probe(false)
- , autolock_untrustedvendor(false)
+ : repo_add_probe(false),
+ repo_refresh_delay(0),
+ autolock_untrustedvendor(false)
{
MIL << "ZConfig singleton created." << endl;
Pathname confpath("/etc/zypp/zypp.conf");
{
string entry(it->first);
string value(it->second);
- //MIL << (*it).first << endl;
+ // DBG << (*it).first << "=" << (*it).second << endl;
if ( section == "main" )
{
if ( entry == "arch" )
{
repo_add_probe = (value == "1");
}
+ else if ( entry == "repo.refresh.delay" )
+ {
+ str::strtonum(value, repo_refresh_delay);
+ }
}
else if ( section == "locking" )
{
Pathname cfg_known_repos_path;
bool repo_add_probe;
+ unsigned repo_refresh_delay;
// [locking]
bool autolock_untrustedvendor;
{
return _pimpl->repo_add_probe;
}
-
+
+ unsigned ZConfig::repo_refresh_delay() const
+ {
+ return _pimpl->repo_refresh_delay;
+ }
+
bool ZConfig::autolock_untrustedvendor() const
{
return _pimpl->autolock_untrustedvendor;
* repo.add.probe
*/
bool repo_add_probe() const;
-
+
+ /**
+ * Amount of time in minutes that must pass before another refresh.
+ */
+ unsigned repo_refresh_delay() const;
+
/**
* Whether untrusted vendor should be autolocked
/ config option