Author: dmacvicar
Date: Sat Feb 2 00:19:51 2008
New Revision: 8440
URL: http://svn.opensuse.org/viewcvs/zypp?rev=8440&view=rev
Log:
- move the cookie code to RepoStatus to reuse it in target
Modified:
branches/tmp/ma/jump_sat/libzypp/zypp/RepoManager.cc
branches/tmp/ma/jump_sat/libzypp/zypp/RepoStatus.cc
branches/tmp/ma/jump_sat/libzypp/zypp/RepoStatus.h
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/RepoManager.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/RepoManager.cc?rev=8440&r1=8439&r2=8440&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/RepoManager.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/RepoManager.cc Sat Feb 2 00:19:51 2008
@@ -873,28 +873,11 @@
RepoStatus RepoManager::cacheStatus( const RepoInfo &info ) const
{
- RepoStatus status;
+
Pathname base = _pimpl->options.repoCachePath + info.alias();
- Pathname solvfile = base.extend(".solv");
Pathname cookiefile = base.extend(".cookie");
- std::ifstream file(cookiefile.c_str());
- if (!file) {
- ZYPP_THROW (Exception( "Can't open " + cookiefile.asString() ) );
- }
-
- std::string buffer;
- while(file && !file.eof()) {
- getline(file, buffer);
- }
-
- std::vectorstd::string words;
- if ( str::split( buffer, std::back_inserter(words) ) != 2 )
- ZYPP_THROW (Exception( "corrupt file " + cookiefile.asString() ) );
-
- status.setTimestamp(Date(str::strtonum(words[1])));
- status.setChecksum(words[0]);
- return status;
+ return RepoStatus::fromCookieFile(cookiefile);
}
void RepoManager::setCacheStatus( const string &alias, const RepoStatus &status )
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/RepoStatus.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/RepoStatus.cc?rev=8440&r1=8439&r2=8440&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/RepoStatus.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/RepoStatus.cc Sat Feb 2 00:19:51 2008
@@ -11,7 +11,11 @@
*/
#include <iostream>
#include <sstream>
+#include <vector>
+#include <algorithm>
+#include <fstream>
//#include "zypp/base/Logger.h"
+#include "zypp/base/String.h"
#include "zypp/RepoStatus.h"
#include "zypp/PathInfo.h"
@@ -78,6 +82,29 @@
RepoStatus::~RepoStatus()
{}
+ RepoStatus RepoStatus::fromCookieFile( const Pathname &cookiefile )
+ {
+ RepoStatus status;
+
+ std::ifstream file(cookiefile.c_str());
+ if (!file) {
+ ZYPP_THROW (Exception( "Can't open " + cookiefile.asString() ) );
+ }
+
+ std::string buffer;
+ while(file && !file.eof()) {
+ getline(file, buffer);
+ }
+
+ std::vectorstd::string words;
+ if ( str::split( buffer, std::back_inserter(words) ) != 2 )
+ ZYPP_THROW (Exception( "bad cookie file " + cookiefile.asString() ) );
+
+ status.setTimestamp(Date(str::strtonum(words[1])));
+ status.setChecksum(words[0]);
+ return status;
+ }
+
RepoStatus::RepoStatus( const Pathname &path )
: _pimpl( new Impl() )
{
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/RepoStatus.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/RepoStatus.h?rev=8440&r1=8439&r2=8440&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/RepoStatus.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/RepoStatus.h Sat Feb 2 00:19:51 2008
@@ -41,6 +41,14 @@
public:
/**
+ * reads the status from a file which contains the
+ * checksum and timestamp in each line.
+ *
+ * \throws Exception If the file is not valid or accessible
+ */
+ static RepoStatus fromCookieFile( const Pathname &path );
+
+ /**
* Checksum of the repository.
* Usually the checksum of the index, but any
* checksum that changes when the repository changes
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org