From: Michael Andres Date: Tue, 13 Oct 2009 14:04:56 +0000 (+0200) Subject: MediaAria2c: Prepare reporting of partial downloads so one could retry with --continue X-Git-Tag: 6.18.1~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0a19ae6017dba26c6b770994194f496bdad2636f;p=platform%2Fupstream%2Flibzypp.git MediaAria2c: Prepare reporting of partial downloads so one could retry with --continue --- diff --git a/zypp/media/MediaAria2c.cc b/zypp/media/MediaAria2c.cc index b7edd9c..0118cca 100644 --- a/zypp/media/MediaAria2c.cc +++ b/zypp/media/MediaAria2c.cc @@ -292,6 +292,7 @@ void MediaAria2c::getFileCopy( const Pathname & filename , const Pathname & targ // (bnc #513944) [#1 SIZE:8.3MiB/10.1MiB(82%) CN:5 SPD:3.8MiBs] // we save it until we find a string with FILE: later string progressLine; + int progress = 0; // file line, which tell which file is the previous progress // ie: FILE: ./packages.FL.gz double average_speed = 0; @@ -300,6 +301,9 @@ void MediaAria2c::getFileCopy( const Pathname & filename , const Pathname & targ // here we capture aria output exceptions vector ariaExceptions; + // TODO: Detect partial downloads! + bool partialDownload = false; // Whether it makes sense to retry with --continue! + //Process response for(std::string ariaResponse( aria.receiveLine()); ariaResponse.length(); @@ -342,7 +346,7 @@ void MediaAria2c::getFileCopy( const Pathname & filename , const Pathname & targ if ( ! progressLine.empty() ) { // get the percentage (progress) data - int progress = 0; + progress = 0; size_t left_bound = progressLine.find('(',0) + 1; size_t count = progressLine.find('%',left_bound) - left_bound; string progressStr = progressLine.substr(left_bound, count); @@ -437,6 +441,22 @@ void MediaAria2c::getFileCopy( const Pathname & filename , const Pathname & targ case 1: // unknown default: { + if ( partialDownload ) + { + // Ask for retry on partial downloads, when it makes sense to retry with --continue! + // Other errors are handled by the layers above. + MediaException e(str::form(_("Download interrupted at %d%%"), progress )); + for_(it, ariaExceptions.begin(), ariaExceptions.end()) + e.addHistory(*it); + + DownloadProgressReport::Action action = report->problem( _url, DownloadProgressReport::ERROR, e.asUserHistory() ); + if ( action == DownloadProgressReport::RETRY ) + { + retry = true; + continue; + } + } + // TranslatorExplanation: Failed to download from . MediaException e(str::form(_("Failed to download %s from %s"), filename.c_str(), _url.asString().c_str())); for_(it, ariaExceptions.begin(), ariaExceptions.end())