Author: dmacvicar
Date: Wed Nov 5 18:46:08 2008
New Revision: 11582
URL: http://svn.opensuse.org/viewcvs/zypp?rev=11582&view=rev
Log:
backup, trying to get flavor cache working
Modified:
trunk/libzypp/zypp/target/TargetImpl.cc
trunk/libzypp/zypp/target/TargetImpl.h
Modified: trunk/libzypp/zypp/target/TargetImpl.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/TargetImpl.cc?rev=11582&r1=11581&r2=11582&view=diff
==============================================================================
--- trunk/libzypp/zypp/target/TargetImpl.cc (original)
+++ trunk/libzypp/zypp/target/TargetImpl.cc Wed Nov 5 18:46:08 2008
@@ -24,6 +24,7 @@
#include "zypp/base/Iterator.h"
#include "zypp/base/Gettext.h"
#include "zypp/base/IOStream.h"
+#include "zypp/base/Functional.h"
#include "zypp/base/UserRequestException.h"
#include "zypp/ZConfig.h"
@@ -52,7 +53,7 @@
#include "zypp/sat/Pool.h"
-using std::endl;
+using namespace std;
///////////////////////////////////////////////////////////////////
namespace zypp
@@ -294,54 +295,121 @@
HistoryLog::setRoot(_root);
- // create the anonymous unique id
- // this value is used for statistics
- Pathname idpath( home() / "AnonymousUniqueId");
+ createAnonymousId();
- if ( ! PathInfo( idpath ).isExist() )
- {
- MIL << "creating anonymous unique id" << endl;
- // if the file does not exist we need to generate the uuid file
- const char* argv[] =
- {
- "/usr/bin/uuidgen",
- "-r",
- "-t",
- NULL
- };
-
- ExternalProgram prog( argv,
- ExternalProgram::Normal_Stderr,
- false, -1, true);
- std::string line;
- std::ofstream idfile;
- // make sure the path exists
- filesystem::assert_dir( home() );
- idfile.open( idpath.c_str() );
-
- if ( idfile.good() )
- {
- for(line = prog.receiveLine();
- ! line.empty();
- line = prog.receiveLine() )
- {
- MIL << line << endl;
+ MIL << "Initialized target on " << _root << endl;
+ }
- idfile << line;
- }
- prog.close();
- }
- else
- {
- // FIXME, should we ignore the error?
- ZYPP_THROW(Exception("Can't open anonymous id file '" + idpath.asString() + "' for writing"));
- }
+ /**
+ * generates a random id using uuidgen
+ */
+ static string generateRandomId()
+ {
+ string id;
+ const char* argv[] =
+ {
+ "/usr/bin/uuidgen",
+ "-r",
+ "-t",
+ NULL
+ };
+
+ ExternalProgram prog( argv,
+ ExternalProgram::Normal_Stderr,
+ false, -1, true);
+ std::string line;
+ for(line = prog.receiveLine();
+ ! line.empty();
+ line = prog.receiveLine() )
+ {
+ MIL << line << endl;
+ id = line;
+ break;
}
+ prog.close();
+ return id;
+ }
+
+ /**
+ * updates the content of \p filename
+ * if \p condition is true, setting the content
+ * the the value returned by \p value
+ */
+ void updateFileContent( const Pathname &filename,
+ boost::function