- Changed to construct localRoot on the fly, since
authorMarius Tomaschewski <mt@suse.de>
Tue, 28 Feb 2006 17:30:46 +0000 (17:30 +0000)
committerMarius Tomaschewski <mt@suse.de>
Tue, 28 Feb 2006 17:30:46 +0000 (17:30 +0000)
  the attach point is changed while reattach

zypp/media/MediaAccess.cc
zypp/media/MediaAccess.h
zypp/media/MediaHandler.cc
zypp/media/MediaHandler.h

index 9a8d83c..389dd1d 100644 (file)
@@ -201,7 +201,7 @@ MediaAccess::isAttached() const
 
 // local directory that corresponds to medias url
 // If media is not open an empty pathname.
-const Pathname &
+Pathname
 MediaAccess::localRoot() const
 {
   if ( !_handler )
index e03c3ae..40c1250 100644 (file)
@@ -159,7 +159,7 @@ namespace zypp {
         *
         * If media is not open an empty pathname is returned.
         **/
-       const Pathname & localRoot() const;
+       Pathname localRoot() const;
 
        /**
         * Short for 'localRoot() + pathname', but returns an empty
index 4de3326..0fea09c 100644 (file)
@@ -158,14 +158,17 @@ MediaHandler::attachPoint() const
 void
 MediaHandler::setAttachPoint(const Pathname &path, bool temporary)
 {
-  _localRoot = Pathname();
-
   _attachPoint.reset( new AttachPoint(path, temporary));
-
-  if( !_attachPoint->path.empty())
-    _localRoot = _attachPoint->path + _relativeRoot;
 }
 
+Pathname
+MediaHandler::localRoot() const
+{
+  if( _attachPoint->path.empty())
+    return Pathname();
+  else
+    return _attachPoint->path + _relativeRoot;
+}
 
 ///////////////////////////////////////////////////////////////////
 //
@@ -178,15 +181,10 @@ MediaHandler::setAttachPoint(const Pathname &path, bool temporary)
 void
 MediaHandler::setAttachPoint(const AttachPointRef &ref)
 {
-  _localRoot = Pathname();
-
   if( ref)
     AttachPointRef(ref).swap(_attachPoint);
   else
     _attachPoint.reset( new AttachPoint());
-
-  if( !_attachPoint->path.empty())
-    _localRoot = _attachPoint->path + _relativeRoot;
 }
 
 ///////////////////////////////////////////////////////////////////
@@ -489,7 +487,9 @@ void MediaHandler::attach( bool next )
 //     METHOD NAME : MediaHandler::localPath
 //     METHOD TYPE : Pathname
 //
-Pathname MediaHandler::localPath( const Pathname & pathname ) const {
+Pathname MediaHandler::localPath( const Pathname & pathname ) const
+{
+    Pathname _localRoot( localRoot());
     if ( _localRoot.empty() )
         return _localRoot;
 
@@ -808,7 +808,7 @@ void MediaHandler::releasePath( Pathname pathname ) const
   if ( info.isFile() ) {
     unlink( info.path() );
   } else if ( info.isDir() ) {
-    if ( info.path() != _localRoot ) {
+    if ( info.path() != localRoot() ) {
       recursive_rmdir( info.path() );
     } else {
       clean_dir( info.path() );
index 5b7fed2..4cc2cb2 100644 (file)
@@ -71,21 +71,12 @@ class MediaHandler {
 
        /**
         * The relative root directory of the data on the media.
-        * See also _localRoot and urlpath_below_attachpoint_r
+        * See also localRoot() and urlpath_below_attachpoint_r
         * constructor argument.
         */
        Pathname _relativeRoot;
 
        /**
-        * The local directory that corresponds to the media url.
-        * With NFS it's the '_attachPoint', as the directory on the
-        * server is mounted. With CD/DVD it's 'attach point+_relativeRoot'
-        * because the CDs root directory is mounted. And with CIFS
-        * it's '_url.path() without the shares name'.
-        **/
-       Pathname _localRoot;
-
-       /**
         * True if concrete handler downloads files to the local
         * filesystem. If true releaseFile/Dir will delete them.
         **/
@@ -254,7 +245,7 @@ class MediaHandler {
         * Call concrete handler to provide file below attach point.
         *
         * Default implementation provided, that returns whether a file
-        * is located at '_localRoot + filename'.
+        * is located at 'localRoot + filename'.
         *
         * Asserted that media is attached.
         *
@@ -285,7 +276,7 @@ class MediaHandler {
         * directory content.
         *
         * Default implementation provided, that returns whether a directory
-        * is located at '_localRoot + dirname'.
+        * is located at 'localRoot + dirname'.
         *
         * Asserted that media is attached.
         *
@@ -302,7 +293,7 @@ class MediaHandler {
         * directory content.
         *
         * Default implementation provided, that returns the content of a
-        * directory at '_localRoot + dirnname' retrieved via 'readdir'.
+        * directory at 'localRoot + dirnname' retrieved via 'readdir'.
         *
         * Asserted that media is attached and retlist is empty.
         *
@@ -419,7 +410,7 @@ class MediaHandler {
         *
         * Returns empty pathname if E_bad_attachpoint
         **/
-       const Pathname & localRoot() const { return _localRoot; }
+       Pathname localRoot() const;
 
        /**
         * Files provided will be available at 'localPath(filename)'.