- Fixed repo::provideFile to set a deleter for downloaded files
authorMichael Andres <ma@suse.de>
Thu, 19 Jul 2007 13:50:33 +0000 (13:50 +0000)
committerMichael Andres <ma@suse.de>
Thu, 19 Jul 2007 13:50:33 +0000 (13:50 +0000)
  (#293004).

VERSION.cmake
devel/devel.ma/Main.cc
zypp/repo/RepoProvideFile.cc

index c29ecd9..6a0f8de 100644 (file)
@@ -47,4 +47,4 @@
 SET(LIBZYPP_MAJOR "3")
 SET(LIBZYPP_MINOR "11")
 SET(LIBZYPP_COMPATMINOR "10")
-SET(LIBZYPP_PATCH "9")
+SET(LIBZYPP_PATCH "10")
index 0f4f302..bec223c 100644 (file)
@@ -4,13 +4,24 @@
 #include "zypp/base/LogTools.h"
 #include "zypp/base/InputStream.h"
 
-#include "zypp/parser/IniDict.h"
+#include "zypp/RepoManager.h"
 
 using std::endl;
 using namespace zypp;
 
 ///////////////////////////////////////////////////////////////////
 
+RepoManager makeRepoManager( const Pathname & mgrdir_r )
+{
+  RepoManagerOptions mgropt;
+
+  mgropt.repoCachePath    = mgrdir_r/"cache";
+  mgropt.repoRawCachePath = mgrdir_r/"raw_cache";
+  mgropt.knownReposPath   = mgrdir_r/"repos";
+
+  return RepoManager( mgropt );
+}
+
 /******************************************************************
 **
 **      FUNCTION NAME : main
@@ -20,23 +31,31 @@ int main( int argc, char * argv[] )
 {
   INT << "===[START]==========================================" << endl;
 
-  Pathname file( "test.ini" );
-  InputStream is( file );
-  parser::IniDict dict( is );
+  RepoManager repoManager( makeRepoManager( "/tmp/myrepos" ) );
+  RepoInfoList repos = repoManager.knownRepositories();
+  SEC << repos << endl;
 
-  SEC << endl;
-  for_( it, dict.sectionsBegin(), dict.sectionsEnd() )
+  if ( repos.empty() )
   {
-    MIL << (*it) << endl;
-
-    for_( ent, dict.entriesBegin(*it), dict.entriesEnd(*it) )
-    {
-      DBG << "'" << (*ent).first << "'='" << (*ent).second << "'" << endl;
-    }
+    RepoInfo nrepo;
+    nrepo
+       .setAlias( "factorytest" )
+       .setName( "Test Repo for factory." )
+       .setEnabled( true )
+       .setAutorefresh( false )
+       .addBaseUrl( Url("ftp://dist.suse.de/install/stable-x86/") );
+
+    repoManager.addRepository( nrepo );
+    repos = repoManager.knownRepositories();
+    SEC << repos << endl;
+
+//    SEC << "refreshMetadat" << endl;
+//    repoManager.refreshMetadata( nrepo );
+//    SEC << "buildCache" << endl;
+//    repoManager.buildCache( nrepo );
+//    SEC << "------" << endl;
   }
-  SEC << endl;
 
   INT << "===[END]============================================" << endl << endl;
   return 0;
 }
-
index 5bac60c..38c7a8d 100644 (file)
@@ -54,26 +54,6 @@ namespace zypp
         function<bool ( int )> _redirect;
       };
 
-      /** ManagedFile Dispose functor.
-       * The Pathname argument is ignored, as Repository::releaseFile expects the filename
-       * relative to the medias root (i.e. same args as to provideFile).
-      */
-      struct RepoReleaseFile
-      {
-       RepoReleaseFile( Repository repo_r, const Pathname & location_r, unsigned mediaNr_r )
-         : _repo( repo_r ), _location( location_r ), _medianr( mediaNr_r )
-       {}
-
-       void operator()( const Pathname & /*UNUSED*/ )
-       {
-         //_repo.releaseFile( _location, _medianr );
-       }
-
-       Repository _repo;
-       Pathname   _location;
-       unsigned   _medianr;
-      };
-
       /////////////////////////////////////////////////////////////////
     } // namespace
     ///////////////////////////////////////////////////////////////////
@@ -107,8 +87,13 @@ namespace zypp
 
           MediaSetAccess access(url);
 
-          ManagedFile ret( access.provideFile(loc_r),
-                          RepoReleaseFile( repo_r, loc_r.filename(), loc_r.medianr() ) );
+          ManagedFile ret( access.provideFile(loc_r) );
+
+          std::string scheme( url.getScheme() );
+          if ( scheme == "http" || scheme == "https" || scheme == "ftp" )
+          {
+            ret.setDispose( filesystem::unlink );
+          }
 
           if ( loc_r.checksum().empty() )
           {