const void Source_Ref::releaseDir(const Pathname & dir_r,
const unsigned media_nr,
- const bool recursive)
+ bool recursive)
{ _pimpl->releaseDir(dir_r, media_nr, recursive); }
- const bool Source_Ref::enabled() const
+ bool Source_Ref::enabled() const
{ return _pimpl->enabled(); }
void Source_Ref::enable()
std::string Source_Ref::checksum() const
{ return _pimpl->checksum(); }
- const bool Source_Ref::autorefresh() const
+ bool Source_Ref::autorefresh() const
{ return _pimpl->autorefresh(); }
- void Source_Ref::setAutorefresh( const bool enable_r )
+ void Source_Ref::setAutorefresh( bool enable_r )
{ _pimpl->setAutorefresh( enable_r ); }
void Source_Ref::refresh()
const Pathname & Source_Ref::path (void) const
{ return _pimpl->path (); }
- const bool Source_Ref::baseSource() const
+ bool Source_Ref::baseSource() const
{ return _pimpl->baseSource(); }
const Pathname & Source_Ref::cacheDir (void) const
const Pathname providePackage( Package::constPtr package );
/** Provide a file to local filesystem */
- const Pathname provideFile(const Pathname & file_r,
- const unsigned media_nr = 1);
- const Pathname provideDirTree(const Pathname & dir_r,
- const unsigned media_nr = 1);
+ const Pathname provideFile(const Pathname & file_r, const unsigned media_nr = 1);
+ const Pathname provideDirTree(const Pathname & dir_r, const unsigned media_nr = 1);
- const void releaseFile(const Pathname & file_r,
- const unsigned media_nr = 1);
- const void releaseDir(const Pathname & dir_r,
- const unsigned media_nr = 1,
- const bool recursive = false);
+ const void releaseFile(const Pathname & file_r, const unsigned media_nr = 1);
+ const void releaseDir(const Pathname & dir_r, const unsigned media_nr = 1, bool recursive = false);
- const bool enabled() const;
+ bool enabled() const;
void enable();
void disable();
- const bool autorefresh() const;
- void setAutorefresh( const bool enable_r );
+ bool autorefresh() const;
+ void setAutorefresh( bool enable_r );
void refresh();
void storeMetadata(const Pathname & cache_dir_r);
void setUrl( const Url & url );
bool remote() const;
const Pathname & path (void) const;
- const bool baseSource() const;
+ bool baseSource() const;
//@}
public:
static Source_Ref::Impl_Ptr createSourceImpl( const media::MediaId & media_r,
const SourceInfo &context )
{
- MIL << "pre pass type: " << _SourceImpl::typeString() << endl;
Source_Ref::Impl_Ptr impl( new _SourceImpl );
- MIL << "pass type: " << _SourceImpl::typeString() << endl;
// note, base_source is a tribool, if indeterminate we fallback to false
+ //MIL << "Going to call factory ctor:" << endl;
+ //MIL << context << endl;
impl->factoryCtor( media_r, context.path(), context.alias(), context.cacheDir(), context.baseSource(), context.autorefresh() );
- MIL << "pass 2 type: " << _SourceImpl::typeString() << endl;
return impl;
}
};
template<class _SourceImpl>
Source_Ref SourceFactory::createSourceImplWorkflow( media::MediaId id, const SourceInfo &context )
{
- MIL << "Trying (pre) to create source of type " << _SourceImpl::typeString() << endl;
+ //MIL << "Trying (pre) to create source of type " << _SourceImpl::typeString() << endl;
callback::SendReport<SourceCreateReport> report;
bool retry = true;
while (retry)
MIL << "Initializing from cache" << endl;
}
+ bool calculated_autorefresh = auto_refresh;
// Sane default for unknown autorefresh
if ( auto_refresh == indeterminate )
- auto_refresh = media::MediaAccess::canBeVolatile( url_r );
+ calculated_autorefresh = media::MediaAccess::canBeVolatile( url_r );
- SourceInfo context( url_r, path_r, alias_r, cache_dir_r, auto_refresh );
+ //SourceInfo( url, path, alias, cache_dir, autorefresh );
+ SourceInfo context( url_r, path_r, alias_r, cache_dir_r, calculated_autorefresh );
context.setBaseSource( base_source );
context.setType( type );
*/
bool SourceManager::restore( Pathname root_r, bool use_caches, const std::string &alias_filter, const std::string &url_filter )
{
- MIL << "SourceManager restore ('" << root_r << ( use_caches ? "' (use_caches)" : "'" )
- << ", alias_filter '" << alias_filter
- << ", url_filter '" << url_filter << "')" << endl;
+ MIL << "SourceManager restore ('" << root_r << ( use_caches ? "' (use_caches)" : "'" ) << ", alias_filter '" << alias_filter << ", url_filter '" << url_filter << "')" << endl;
- if (! _sources.empty() ) {
+ if (! _sources.empty() )
+ {
- // if we've already restored sources and this is an unfiltered call, reject it.
+ // if we've already restored sources and this is an unfiltered call, reject it.
- if (alias_filter.empty()
- && url_filter.empty())
- {
- ZYPP_THROW(SourcesAlreadyRestoredException());
- //Exception ( N_("At least one source already registered, cannot restore sources from persistent store.") ) );
- }
+ if (alias_filter.empty()
+ && url_filter.empty())
+ {
+ ZYPP_THROW(SourcesAlreadyRestoredException());
+ //Exception ( N_("At least one source already registered, cannot restore sources from persistent store.") ) );
+ }
- // check filters against already restore sources and check for duplicates.
- //
- for (SourceMap::const_iterator it = _sources.begin(); it != _sources.end(); ++it) {
- if (!alias_filter.empty()
- && (alias_filter == it->second.alias()) )
- {
- MIL << "Source with alias '" << alias_filter << "' already restored.";
- return true;
- }
- if (!url_filter.empty()
- && (url_filter == it->second.url().asString()) )
- {
- MIL << "Source with url '" << url_filter << "' already restored.";
- return true;
- }
- }
+ // check filters against already restore sources and check for duplicates.
+ //
+ for (SourceMap::const_iterator it = _sources.begin(); it != _sources.end(); ++it)
+ {
+ if (!alias_filter.empty() && (alias_filter == it->second.alias()) )
+ {
+ MIL << "Source with alias '" << alias_filter << "' already restored.";
+ return true;
+ }
+
+ if (!url_filter.empty() && (url_filter == it->second.url().asString()) )
+ {
+ MIL << "Source with url '" << url_filter << "' already restored.";
+ return true;
+ }
+ }
}
FailedSourcesRestoreException report;
for( std::list<source::SourceInfo>::iterator it = new_sources.begin(); it != new_sources.end(); ++it)
{
- if ( !alias_filter.empty() // check alias filter, if set
- && (alias_filter != it->alias()) )
- {
- continue;
- }
+ if ( !alias_filter.empty() // check alias filter, if set
+ && (alias_filter != it->alias()) )
+ {
+ continue;
+ }
- if ( !url_filter.empty() // check url filter, if set
+ if ( !url_filter.empty() // check url filter, if set
&& (url_filter != it->url().asString()) )
- {
- continue;
- }
+ {
+ continue;
+ }
+
+ // Note: Url(it->url).asString() to hide password in logs
+ MIL << "Restoring source: url:[" << it->url().asString() << "] product_dir:[" << it->path() << "] alias:[" << it->alias() << "] cache_dir:[" << it->cacheDir() << "] auto_refresh:[ " << it->autorefresh() << "]" << endl;
- // Note: Url(it->url).asString() to hide password in logs
- MIL << "Restoring source: url:[" << it->url().asString() << "] product_dir:[" << it->path() << "] alias:[" << it->alias() << "] cache_dir:[" << it->cacheDir() << "] auto_refresh:[ " << it->autorefresh() << "]" << endl;
-
- SourceId id = 0;
-
- try {
- id = addSource( SourceFactory().createFrom(it->type(), it->url(), it->path(), it->alias(), it->cacheDir(), false, it->autorefresh()) );
- }
- catch (const Exception &expt )
- {
- // Note: Url(it->url).asString() to hide password in logs
- ERR << "Unable to restore source from " << it->url().asString()
- << endl;
-
- id = 0;
- Url url2;
- try {
- url2 = it->url();
- std::string scheme( url2.getScheme());
-
- if( (scheme == "cd" || scheme == "dvd") &&
- !url2.getQueryParam("devices").empty())
- {
- url2.setQueryParam("devices", "");
-
- DBG << "CD/DVD devices changed - try again without a devices list"
- << std::endl;
-
- id = addSource( SourceFactory().createFrom(url2, it->path(), it->alias(), it->cacheDir(), false ) );
-
- // This worked ... update it->url ?
- //it->url = url2.asCompleteString();
- }
- }
- catch (const Exception &e2)
- {
- // Note: Url(it->url).asString() to hide password in logs
- ERR << "Unable to restore source from " << url2.asString()
- << endl;
- id = 0;
- ZYPP_CAUGHT(e2);
- }
-
- if( id == 0)
- {
- report.append( it->url().asString() + it->path().asString(), it->alias(), expt );
- continue;
- }
- }
-
- DBG << "Added source as id " << id << endl;
- // should not throw, we've just created the source
- Source_Ref src = findSource( id );
-
- if ( it->enabled() ) {
- DBG << "enable source" << endl;
- src.enable();
- }
- else {
- DBG << "disable source" << endl;
- src.disable();
- }
+ SourceId id = 0;
+
+ try
+ {
+ Source_Ref src = SourceFactory().createFrom(it->type(), it->url(), it->path(), it->alias(), it->cacheDir(), false, it->autorefresh());
+ id = addSource(src);
+ }
+ catch (const Exception &expt )
+ {
+ // Note: Url(it->url).asString() to hide password in logs
+ ERR << "Unable to restore source from " << it->url().asString() << endl;
+
+ id = 0;
+ Url url2;
+ try
+ {
+ url2 = it->url();
+ std::string scheme( url2.getScheme());
+
+ if( (scheme == "cd" || scheme == "dvd") && !url2.getQueryParam("devices").empty())
+ {
+ url2.setQueryParam("devices", "");
+ DBG << "CD/DVD devices changed - try again without a devices list" << std::endl;
+
+ id = addSource( SourceFactory().createFrom(url2, it->path(), it->alias(), it->cacheDir(), false ) );
+
+ // This worked ... update it->url ?
+ //it->url = url2.asCompleteString();
+ }
+ }
+ catch (const Exception &e2)
+ {
+ // Note: Url(it->url).asString() to hide password in logs
+ ERR << "Unable to restore source from " << url2.asString()
+ << endl;
+ id = 0;
+ ZYPP_CAUGHT(e2);
+ }
+
+ if( id == 0)
+ {
+ report.append( it->url().asString() + it->path().asString(), it->alias(), expt );
+ continue;
+ }
+ }
+
+ DBG << "Added source as id " << id << endl;
+ // should not throw, we've just created the source
+ Source_Ref src = findSource( id );
+
+ if ( it->enabled() )
+ {
+ DBG << "enable source" << endl;
+ src.enable();
+ }
+ else
+ {
+ DBG << "disable source" << endl;
+ src.disable();
+ }
}
if( !report.empty() )
{
- ZYPP_THROW(report);
+ ZYPP_THROW(report);
}
MIL << "SourceManager restore done." << endl;
{
if ( (_helper.content(child) == "true") || (_helper.content(child) == "1") )
dataPtr->setAutorefresh(true);
- if ( (_helper.content(child) == "false") || (_helper.content(child) == "0") )
+ else if ( (_helper.content(child) == "false") || (_helper.content(child) == "0") )
dataPtr->setAutorefresh(false);
else
dataPtr->setAutorefresh(boost::indeterminate);
const Pathname & path_r,
const std::string & alias_r,
const Pathname cache_dir_r,
- bool base_source,
+ bool base_source,
bool auto_refresh )
{
_media_set = new MediaSet( selfSourceRef() );
_cache_dir = cache_dir_r;
_subscribed = true;
_base_source = base_source;
+
+ MIL << "Setting autorefresh: " << auto_refresh << endl;
_autorefresh = auto_refresh;
try
}
}
+ bool SourceImpl::enabled() const
+ {
+ return _enabled;
+ }
+
+ void SourceImpl::disable()
+ {
+ _enabled = false;
+ }
+
+ bool SourceImpl::autorefresh() const
+ {
+ return _autorefresh;
+ }
+
+ void SourceImpl::setAutorefresh( bool enable )
+ {
+ MIL << "Changing source [" << alias() << "] [" << url() << "] to autorefresh: " << enable << endl;
+ _autorefresh = enable;
+ }
+
const ResStore & SourceImpl::resolvables() const
{
if ( !_res_store_initialized )
<< _url << "(" << _path << ")";
if ( ! _cache_dir.empty() )
str << "; cache " << _cache_dir;
+
+ str << "; autorefresh: " << _autorefresh;
+ str << "; enabled: " << _enabled;
str << "}";
return str;
void changeMedia(const media::MediaId & media_r, const Pathname & path_r);
- const bool enabled() const
- { return _enabled; }
-
+ bool enabled() const;
void enable();
-
- void disable()
- { _enabled = false; }
-
- const bool autorefresh() const
- { return _autorefresh; }
-
- void setAutorefresh( const bool enable_r )
- { _autorefresh = enable_r; }
-
+ void disable();
+ bool autorefresh() const;
+ void setAutorefresh( bool enable_r );
void refresh();
virtual void storeMetadata(const Pathname & cache_dir_r);
{ return _enabled; }
tribool SourceInfo::autorefresh() const
- { return _enabled; }
+ { return _autorefresh; }
boost::tribool SourceInfo::baseSource() const
{ return _base_source; }
MIL << "Read product: " << _product->summary() << endl;
_prodImpl = p.prodImpl;
- _autorefresh = p.volatile_content && media::MediaAccess::canBeVolatile( _url );
}
catch ( const Exception & e ) {
ZYPP_THROW (SourceMetadataException("Cannot parse content file: " + e.msg()));