Imported Upstream version 14.45.0
[platform/upstream/libzypp.git] / zypp / media / MediaHandler.cc
index e0520a4..18c05fe 100644 (file)
@@ -14,7 +14,6 @@
 #include <fstream>
 #include <sstream>
 
-#include "zypp/ZConfig.h"
 #include "zypp/TmpPath.h"
 #include "zypp/Date.h"
 #include "zypp/base/LogTools.h"
@@ -57,7 +56,7 @@ MediaHandler::MediaHandler ( const Url &      url_r,
                             const bool       does_download_r )
     : _mediaSource()
     , _attachPoint( new AttachPoint())
-    , _attachPointHint()
+    , _AttachPointHint()
     , _relativeRoot( urlpath_below_attachpoint_r)
     , _does_download( does_download_r )
     , _attach_mtime(0)
@@ -269,8 +268,8 @@ MediaHandler::setAttachPoint(const AttachPointRef &ref)
 void
 MediaHandler::attachPointHint(const Pathname &path, bool temporary)
 {
-  _attachPointHint.path = path;
-  _attachPointHint.temp = temporary;
+  _AttachPointHint.path = path;
+  _AttachPointHint.temp = temporary;
 }
 
 ///////////////////////////////////////////////////////////////////
@@ -284,7 +283,7 @@ MediaHandler::attachPointHint(const Pathname &path, bool temporary)
 AttachPoint
 MediaHandler::attachPointHint() const
 {
-  return _attachPointHint;
+  return _AttachPointHint;
 }
 
 ///////////////////////////////////////////////////////////////////
@@ -341,34 +340,34 @@ MediaHandler::setAttachPrefix(const Pathname &attach_prefix)
 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;