commit 20a8d8682a6adee70a209d0a16ba1b6c2d258943
Author: Michael Andres
Date: Thu Jan 22 15:29:48 2009 +0100
Fix plaindir checksum computation not to to follow symlinks (bnc #464778)
---
zypp/parser/plaindir/RepoParser.cc | 33 ++++++++++++++++-----------------
1 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/zypp/parser/plaindir/RepoParser.cc b/zypp/parser/plaindir/RepoParser.cc
index 1c11cd7..feb64aa 100644
--- a/zypp/parser/plaindir/RepoParser.cc
+++ b/zypp/parser/plaindir/RepoParser.cc
@@ -27,35 +27,34 @@ namespace parser
namespace plaindir
{ /////////////////////////////////////////////////////////////////
-static time_t recursive_timestamp( const Pathname &dir )
+static void recursive_timestamp( const Pathname &dir, time_t & max )
{
- time_t max = PathInfo(dir).mtime();
std::liststd::string dircontent;
- if (filesystem::readdir( dircontent, dir, false) != 0)
- { // dont look for dot files
- ERR << "readdir " << dir << " failed" << endl;
- return 0;
- }
+ if ( filesystem::readdir( dircontent, dir, false/*no dots*/ ) != 0 )
+ return; // readdir logged the error
- for (std::liststd::string::const_iterator it = dircontent.begin();
- it != dircontent.end();
- ++it)
+ for_( it, dircontent.begin(), dircontent.end() )
{
- Pathname dir_path = dir + *it;
- if ( PathInfo(dir_path).isDir())
+ PathInfo pi( dir + *it, PathInfo::LSTAT );
+ if ( pi.isDir() )
{
- time_t val = recursive_timestamp(dir_path);
- if ( val > max )
- max = val;
+ recursive_timestamp( pi.path(), max );
+ if ( pi.mtime() > max )
+ max = pi.mtime();
}
}
- return max;
}
RepoStatus dirStatus( const Pathname &dir )
{
+ time_t t = 0;
+ PathInfo pi(dir);
+ if ( pi.isDir() )
+ {
+ t = pi.mtime();
+ recursive_timestamp(dir,t);
+ }
RepoStatus status;
- time_t t = recursive_timestamp(dir);
status.setTimestamp(Date(t));
status.setChecksum(str::numstring(t));
return status;
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org