From: Michael Andres Date: Thu, 19 Jul 2007 13:50:33 +0000 (+0000) Subject: - Fixed repo::provideFile to set a deleter for downloaded files X-Git-Tag: BASE-SuSE-Linux-10_3-Branch~526 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8978ba11c54673079f711106beafab4018f2ddc7;p=platform%2Fupstream%2Flibzypp.git - Fixed repo::provideFile to set a deleter for downloaded files (#293004). --- diff --git a/VERSION.cmake b/VERSION.cmake index c29ecd9..6a0f8de 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -47,4 +47,4 @@ SET(LIBZYPP_MAJOR "3") SET(LIBZYPP_MINOR "11") SET(LIBZYPP_COMPATMINOR "10") -SET(LIBZYPP_PATCH "9") +SET(LIBZYPP_PATCH "10") diff --git a/devel/devel.ma/Main.cc b/devel/devel.ma/Main.cc index 0f4f302..bec223c 100644 --- a/devel/devel.ma/Main.cc +++ b/devel/devel.ma/Main.cc @@ -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; } - diff --git a/zypp/repo/RepoProvideFile.cc b/zypp/repo/RepoProvideFile.cc index 5bac60c..38c7a8d 100644 --- a/zypp/repo/RepoProvideFile.cc +++ b/zypp/repo/RepoProvideFile.cc @@ -54,26 +54,6 @@ namespace zypp function _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() ) {