From fbca41c91c3c03297ce291e64acad6b7c55879f9 Mon Sep 17 00:00:00 2001 From: Marius Tomaschewski Date: Fri, 29 Sep 2006 11:49:06 +0000 Subject: [PATCH] - Improved attachPoint handling in cases where the media url provided a path that doesn't exists while construction --- zypp/media/MediaDIR.cc | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/zypp/media/MediaDIR.cc b/zypp/media/MediaDIR.cc index f211288..892c5d2 100644 --- a/zypp/media/MediaDIR.cc +++ b/zypp/media/MediaDIR.cc @@ -67,11 +67,40 @@ namespace zypp { if(next) ZYPP_THROW(MediaNotSupportedException(url())); + // fetch attach point from url again if needed ... + // it may happen that attachPointHint (and attachPoint()) + // does not contain any path, because the directory has + // not existed while the handler was constructed. + if( attachPoint().empty() && !url().getPathName().empty()) + { + Pathname real( getRealPath(url().getPathName())); + + PathInfo adir( real); + if( adir.isDir()) + { + // set attachpoint only if the dir exists + setAttachPoint( real, false); + } + else + { + ZYPP_THROW(MediaBadUrlException(url(), + "Specified path '" + url().getPathName() + "' is and not allowed as media source" + )); + } + } + // attach point is same as source path... we do not mount here - if(attachPoint().empty() || !PathInfo(attachPoint()).isDir()) + if(attachPoint().empty()) + { + ZYPP_THROW(MediaBadUrlException(url(), + "The media URL does not provide any useable directory path" + )); + } + else + if(!PathInfo(attachPoint()).isDir()) { ZYPP_THROW(MediaBadUrlException(url(), - "Specified path '" + attachPoint().asString() + "' is not allowed as media source" + "Specified path '" + attachPoint().asString() + "' is not a directory" )); } -- 2.7.4