Author: jkupec
Date: Tue Jul 10 20:16:01 2007
New Revision: 39297
URL: http://svn.opensuse.org/viewcvs/yast?rev=39297&view=rev
Log:
- added repomedias - vector of MediaSetAccess objects
- SourceProvide*File methods reimplemented with passed
MediaSetAccess object
- SourceReleaseAll() reimplemented
Modified:
branches/REFACTORING-10_3/pkg-bindings/src/PkgModuleFunctions.h
branches/REFACTORING-10_3/pkg-bindings/src/Source.cc
Modified: branches/REFACTORING-10_3/pkg-bindings/src/PkgModuleFunctions.h
URL: http://svn.opensuse.org/viewcvs/yast/branches/REFACTORING-10_3/pkg-bindings/src/PkgModuleFunctions.h?rev=39297&r1=39296&r2=39297&view=diff
==============================================================================
--- branches/REFACTORING-10_3/pkg-bindings/src/PkgModuleFunctions.h (original)
+++ branches/REFACTORING-10_3/pkg-bindings/src/PkgModuleFunctions.h Tue Jul 10 20:16:01 2007
@@ -45,6 +45,7 @@
#include
#include
#include
+#include
#include "PkgError.h"
@@ -100,6 +101,11 @@
// original status
std::vectorzypp::RepoInfo repos_orig;
+ // media set access objects corresponding to repos
+ // when manipulating repos, these should be check as well
+ typedef std::vectorzypp::MediaSetAccess_Ptr RepoMediaVector;
+ RepoMediaVector repomedias;
+
// table for converting libzypp source type to Yast type (for backward compatibility)
std::map type_conversion_table;
@@ -145,7 +151,8 @@
PkgError _last_error;
- zypp::RepoInfo NOREPO;
+ static zypp::RepoInfo NOREPO;
+ static zypp::MediaSetAccess_Ptr NOMEDIA;
/**
* Logging helper:
@@ -155,6 +162,9 @@
zypp::RepoInfo& logFindRepository(zypp::Repository::NumericId id);
zypp::Repository::NumericId createManagedSource(const zypp::Url & url_r,
const zypp::Pathname & path_r, const bool base_source, const std::string& type);
+
+ zypp::MediaSetAccess_Ptr & logFindRepoMedia(RepoMediaVector::size_type id);
+
/**
* provides SourceProvideFile and SourceProvideFileCommon
*/
Modified: branches/REFACTORING-10_3/pkg-bindings/src/Source.cc
URL: http://svn.opensuse.org/viewcvs/yast/branches/REFACTORING-10_3/pkg-bindings/src/Source.cc?rev=39297&r1=39296&r2=39297&view=diff
==============================================================================
--- branches/REFACTORING-10_3/pkg-bindings/src/Source.cc (original)
+++ branches/REFACTORING-10_3/pkg-bindings/src/Source.cc Tue Jul 10 20:16:01 2007
@@ -138,6 +138,32 @@
return NOREPO;
}
+zypp::MediaSetAccess_Ptr & PkgModuleFunctions::logFindRepoMedia(RepoMediaVector::size_type id)
+{
+ try
+ {
+ zypp::MediaSetAccess_Ptr maccess_ptr = repomedias[id];
+ if (maccess_ptr)
+ return repomedias[id];
+ else
+ {
+ y2milestone("MediaSetAccess not found for repository %ld, creating a new one.", id);
+ zypp::RepoInfo repo = logFindRepository(id);
+ maccess_ptr = new zypp::MediaSetAccess(*repo.baseUrlsBegin()); // FIXME handle multiple baseUrls
+ maccess_ptr.swap(repomedias[id]);
+ return repomedias[id];
+ }
+ }
+ catch (...)
+ {
+ y2error("Could not get MediaSetAccess for repository %ld.", id);
+ throw;
+ }
+
+ // return empty media set access object on error
+ return NOMEDIA;
+}
+
/****************************************************************************************
* @builtin SourceSetRamCache
@@ -439,9 +465,20 @@
YCPValue
PkgModuleFunctions::SourceReleaseAll ()
{
- y2milestone("Relesing all sources. WARNING: this method is deprecated and has empty"
- " implementation! If that causes problems, tell libzypp people."
- " If everything works fine without it, just delete it from your code.");
+ y2milestone("Relesing all sources. ");
+
+ for (RepoMediaVector::iterator it = repomedias.begin();
+ it != repomedias.end(); ++it)
+ {
+ try
+ {
+ (*it)->release();
+ }
+ catch (const zypp::media::MediaException & ex)
+ {
+ y2warning("Failed to release media for repo: %s", ex.msg().c_str());
+ }
+ }
return YCPBoolean(true);
}
@@ -789,6 +826,7 @@
CallSourceReportStart(_("Downloading file..."));
zypp::RepoInfo src;
+ zypp::MediaSetAccess_Ptr maccess_ptr;
bool found = true;
extern ZyppRecipients::MediaChangeSensitivity _silent_probing;
@@ -802,20 +840,19 @@
try
{
src = logFindRepository(id->value());
+ maccess_ptr = logFindRepoMedia(id->value());
}
- catch (const zypp::Exception& excpt)
+ catch (...)
{
found = false;
}
- zypp::filesystem::Pathname path;
-
+ zypp::filesystem::Pathname path; // FIXME use ManagedMedia
if (found)
{
try
{
- zypp::MediaSetAccess maccess(*src.baseUrlsBegin());
- path = maccess.provideFile(f->value(), mid->value());
+ path = maccess_ptr->provideFile(f->value(), mid->value());
y2internal("local path: '%s'", path.asString().c_str());
}
catch (const zypp::Exception& excpt)
@@ -902,25 +939,26 @@
PkgModuleFunctions::SourceProvideDir (const YCPInteger& id, const YCPInteger& mid, const YCPString& d)
{
zypp::RepoInfo src;
+ zypp::MediaSetAccess_Ptr maccess_ptr;
bool found = true;
try
{
src = logFindRepository(id->value());
+ maccess_ptr = logFindRepoMedia(id->value());
}
- catch (const zypp::Exception& excpt)
+ catch (...)
{
found = false;
}
- zypp::filesystem::Pathname path;
+ zypp::filesystem::Pathname path; // FIXME user ManagedMedia
if (found)
{
try
{
- zypp::MediaSetAccess maccess(*src.baseUrlsBegin());
- path = maccess.provideDir(d->value(), true, mid->value());
+ path = maccess_ptr->provideDir(d->value(), true, mid->value());
}
catch (const zypp::Exception& excpt)
{
@@ -957,7 +995,7 @@
try {
src = logFindRepository(id->value());
}
- catch (const zypp::Exception& excpt)
+ catch (...)
{
return YCPBoolean(false);
}
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org