mpm

morphux package manager
Log | Files | Refs | README | LICENSE | git clone https://git.ne02ptzero.me/git/mpm

commit ddcb20bf1dec761eca7dc69822a7bf42b8dec507
parent 75623b950cbfd8cc4783cadc029172ba5603b932
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Sun, 13 Dec 2015 00:39:01 +0000

Fix(Multiple dependencies):

Fix a bug with same package added multiples time in the list.

Diffstat:
Minc/Download.hpp | 1+
Msrc/Download.cpp | 13++++++++-----
Msrc/Error.cpp | 5+++--
3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/inc/Download.hpp b/inc/Download.hpp @@ -51,6 +51,7 @@ class Download { std::string _test; Json::Value _response; std::list<Package *> _packList; + std::list<Package *> _packTreated; }; #endif diff --git a/src/Download.cpp b/src/Download.cpp @@ -99,16 +99,18 @@ void Download::_addPackage(std::string name) { std::list<std::string>::iterator it; std::list<Package *>::iterator it2; - for (it2 = this->_packList.begin(); it2 != this->_packList.end() && (*it2)->getName() != name; it2++); - if (it2 != this->_packList.end()) - return ; p = new Package(name, this->_response[name]); + for (it2 = this->_packTreated.begin(); it2 != this->_packTreated.end() && (*it2)->getName() != p->getName(); it2++); + if (it2 != this->_packTreated.end()) { + delete p; + return ; + } if (p->getToInstall()) { if (p->getError() == "") - Error::warning("Package " + name + " already installed, skipping it"); + Error::info("Package " + p->getName() + " already installed, skipping it"); else Error::warning("Package " + name + " can not be found, skipping it"); - delete p; + this->_packTreated.push_back(p); return ; } else if (!p->getToDownload()) { Download::totalSize += p->getSize(); @@ -126,6 +128,7 @@ void Download::_addPackage(std::string name) { for (it = tmp.begin(); it != tmp.end(); it++) this->_addPackage(*it); } + this->_packTreated.push_back(p); this->_packList.push_front(p); } diff --git a/src/Error.cpp b/src/Error.cpp @@ -51,12 +51,13 @@ void Error::execError(void) { return ; buffer << fd.rdbuf(); lines = split(buffer.str(), '\n'); - for (it = lines.end(), r = 0; it != lines.begin() && r < 20 && (*it).substr(0, 6) != "======"; it--, r++); + for (it = (lines.end())--, r = 0, it--; it != lines.begin() && r < 20 && (*it).substr(0, 6) != "======"; it--, r++) { + } if (r == 20) Error::info("Output the last 20 lines. If the information is not here, you might check /var/log/mpm.log"); else Error::info("Ouput"); - for (; it != lines.end(); it++) + for (it++; it != lines.end(); it++) std::cout << RED << "> " << DEF << *it << std::endl; }