#include <fstream>
#include <sstream>
-#include "zypp/ZConfig.h"
#include "zypp/TmpPath.h"
#include "zypp/Date.h"
#include "zypp/base/LogTools.h"
const bool does_download_r )
: _mediaSource()
, _attachPoint( new AttachPoint())
- , _attachPointHint()
+ , _AttachPointHint()
, _relativeRoot( urlpath_below_attachpoint_r)
, _does_download( does_download_r )
, _attach_mtime(0)
void
MediaHandler::attachPointHint(const Pathname &path, bool temporary)
{
- _attachPointHint.path = path;
- _attachPointHint.temp = temporary;
+ _AttachPointHint.path = path;
+ _AttachPointHint.temp = temporary;
}
///////////////////////////////////////////////////////////////////
AttachPoint
MediaHandler::attachPointHint() const
{
- return _attachPointHint;
+ return _AttachPointHint;
}
///////////////////////////////////////////////////////////////////
Pathname
MediaHandler::createAttachPoint() const
{
- Pathname aroot;
+ /////////////////////////////////////////////////////////////////
+ // provide a default (temporary) attachpoint
+ /////////////////////////////////////////////////////////////////
+ const char * defmounts[] = {
+ "/var/adm/mount", filesystem::TmpPath::defaultLocation().c_str(), /**/NULL/**/
+ };
+
Pathname apoint;
- {
- aroot = MediaHandler::_attachPrefix; // explicit request
- if ( ! aroot.empty() )
- apoint = createAttachPoint( aroot );
- }
+ Pathname aroot( MediaHandler::_attachPrefix);
- if ( apoint.empty() ) // fallback to config value
+ if( !aroot.empty())
{
- aroot = ZConfig::instance().download_mediaMountdir();
- if ( ! aroot.empty() )
- apoint = createAttachPoint( aroot );
+ apoint = createAttachPoint(aroot);
}
+ for ( const char ** def = defmounts; *def && apoint.empty(); ++def ) {
+ aroot = *def;
+ if( aroot.empty())
+ continue;
- if ( apoint.empty() ) // fall back to temp space
- {
- aroot = filesystem::TmpPath::defaultLocation();
- if ( ! aroot.empty() )
- apoint = createAttachPoint( aroot );
+ apoint = createAttachPoint(aroot);
}
- if ( apoint.empty() )
- {
+ if ( aroot.empty() ) {
ERR << "Create attach point: Can't find a writable directory to create an attach point" << std::endl;
+ return aroot;
}
- else
- {
+
+ if ( !apoint.empty() ) {
MIL << "Created default attach point " << apoint << std::endl;
}
return apoint;