Author: dmacvicar Date: Mon Jul 9 17:04:08 2007 New Revision: 5934 URL: http://svn.opensuse.org/viewcvs/zypp?rev=5934&view=rev Log: - fix CombinedProgressData to use relative to parents weight - make YUM progress r0ck (tm). Modified: branches/REFACTORING-10_3/libzypp/zypp/ProgressData.cc branches/REFACTORING-10_3/libzypp/zypp/parser/yum/RepoParser.cc Modified: branches/REFACTORING-10_3/libzypp/zypp/ProgressData.cc URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/zypp/ProgressData.cc?rev=5934&r1=5933&r2=5934&view=diff ============================================================================== --- branches/REFACTORING-10_3/libzypp/zypp/ProgressData.cc (original) +++ branches/REFACTORING-10_3/libzypp/zypp/ProgressData.cc Mon Jul 9 17:04:08 2007 @@ -140,12 +140,18 @@ bool CombinedProgressData::operator()( const ProgressData &progress ) { MIL << endl; - ProgressData::value_type increment = progress.val() - _last_value; - int real_increment = (int)((float)(_weight*increment)/100); - //MIL << "Value: " << v << ". Increment of " << increment << ". Real of " << real_increment << endl; + if ( ! progress.hasRange() ) + return _pd.tick(); + + // factor [0,1] of increase in subtask ( ie: before 0,2 now 0.5 ) + float increment = ((float)(progress.val() - _last_value))/(progress.max() - progress.min()); + // how much the subtask affects the parent task ie: 0,1 + float parent_factor = (float)(_weight)/(_pd.max() - _pd.min()); + // real increment of the parent task + float real_increment = parent_factor*increment; _last_value = progress.val(); - return _pd.incr(real_increment); + return _pd.incr( (int)( (_pd.max()-_pd.min()) * real_increment) ); } ///////////////////////////////////////////////////////////////// Modified: branches/REFACTORING-10_3/libzypp/zypp/parser/yum/RepoParser.cc URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/zypp/parser/yum/RepoParser.cc?rev=5934&r1=5933&r2=5934&view=diff ============================================================================== --- branches/REFACTORING-10_3/libzypp/zypp/parser/yum/RepoParser.cc (original) +++ branches/REFACTORING-10_3/libzypp/zypp/parser/yum/RepoParser.cc Mon Jul 9 17:04:08 2007 @@ -42,16 +42,6 @@ namespace yum { - - /** \todo make this through ZYppCallbacks.h */ - bool progress_function( const ProgressData &p ) - { - cout << "Parsing $name_would_come_in_handy [" << p.val() << "%]" << endl; -// cout << "\rParsing $name_would_come_in_handy [" << p << "%]" << flush; - return true; - } - - /** * Structure encapsulating YUM parser data type and filename. */ @@ -324,6 +314,7 @@ totalsize += PathInfo(cache_dir + job.filename()).size(); } + MIL << "Total files size: " << totalsize << endl; _ticks.range(totalsize); _ticks.toMin(); @@ -351,10 +342,11 @@ // parse primary.xml.gz case ResourceType::PRIMARY_e: { + CombinedProgressData jobrcv( _ticks, jobsize ); PrimaryFileReader( cache_dir + job.filename(), bind(&RepoParser::Impl::primary_CB, this, _1), - &progress_function); + jobrcv); break; } @@ -366,7 +358,9 @@ // reset progress reporter max value (number of jobs changed if // there are patches to parse) _ticks.range( _ticks.max() + jobsize ); - + // increase in the total bytes of the file + if (!_ticks.incr( jobsize )) + ZYPP_THROW(AbortRequestException()); break; } @@ -375,6 +369,9 @@ PatchFileReader( cache_dir + job.filename(), bind(&RepoParser::Impl::patch_CB, this, _1)); + // increase in the total bytes of the file + if (!_ticks.incr( jobsize )) + ZYPP_THROW(AbortRequestException()); break; } @@ -382,13 +379,19 @@ { if (!_options.skipOther) { + CombinedProgressData jobrcv( _ticks, jobsize ); OtherFileReader( cache_dir + job.filename(), bind(&RepoParser::Impl::other_CB, this, _1, _2), - &progress_function); + jobrcv); } else + { MIL << "skipping other.xml.gz"; + // increase in the total bytes of the file + if (!_ticks.incr( jobsize )) + ZYPP_THROW(AbortRequestException()); + } break; } @@ -396,14 +399,19 @@ { if (!_options.skipFilelists) { + CombinedProgressData jobrcv( _ticks, jobsize ); FilelistsFileReader( cache_dir + job.filename(), bind(&RepoParser::Impl::filelist_CB, this, _1, _2), - &progress_function); + jobrcv); } else + { MIL << "skipping filelists.xml.gz"; - + // increase in the total bytes of the file + if (!_ticks.incr( jobsize )) + ZYPP_THROW(AbortRequestException()); + } break; } @@ -412,6 +420,9 @@ PatternFileReader( cache_dir + job.filename(), bind(&RepoParser::Impl::pattern_CB, this, _1)); + // increase in the total bytes of the file + if (!_ticks.incr( jobsize )) + ZYPP_THROW(AbortRequestException()); break; } @@ -420,6 +431,9 @@ ProductFileReader( cache_dir + job.filename(), bind(&RepoParser::Impl::product_CB, this, _1)); + // increase in the total bytes of the file + if (!_ticks.incr( jobsize )) + ZYPP_THROW(AbortRequestException()); break; } @@ -430,10 +444,6 @@ << job.filename() << endl; } } - - // increase in the total bytes of the file - if (!_ticks.incr( jobsize )) - ZYPP_THROW(AbortRequestException()); } } -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org