Skip to content

Commit

Permalink
- Updated getPackageSize code.
Browse files Browse the repository at this point in the history
  • Loading branch information
aarnt committed Nov 10, 2020
1 parent 268dea6 commit 8308707
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pkgname=octopi
pkgver=0.10.0
pkgver=0.11.0
pkgrel=1
pkgdesc="This is Octopi, a powerful Pacman frontend using Qt libs"
url="https://tintaescura.com/projects/octopi/"
Expand Down
16 changes: 16 additions & 0 deletions notifier/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "mainwindow.h"
#include "outputdialog.h"
//#include "../src/alpmbackend.h"
#include "../src/strconstants.h"
#include "../src/uihelper.h"
#include "../src/package.h"
Expand Down Expand Up @@ -608,8 +609,23 @@ void MainWindow::doSystemUpgrade()
}
}

//double retSize;

for(const auto &target : qAsConst(*targets))
{
/*
#ifdef ALPM_BACKEND
if (target.downloadSize == 0)
{
retSize=AlpmBackend::getPackageSize(target.name);
totalDownloadSize += retSize;
}
else
totalDownloadSize += target.downloadSize;
#else
totalDownloadSize += target.downloadSize;
#endif
*/
totalDownloadSize += target.downloadSize;
list = list + target.name + QLatin1Char('-') + target.version + QLatin1Char('\n');
}
Expand Down
10 changes: 4 additions & 6 deletions src/alpmbackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,12 @@ QStringList AlpmBackend::getOutdatedList()
/*
* Retrieves package download size
*/
QString AlpmBackend::getPackageSize(const QString &pkgName)
double AlpmBackend::getPackageSize(const QString &pkgName)
{
// create AlpmUtils instance
AlpmUtils* alpm_utils = alpm_utils_new ("/etc/pacman.conf");

alpm_list_t* i;
char size[20];
off_t pkgSize=0;

std::string str = pkgName.toStdString();
const char* p = str.c_str();
Expand All @@ -311,8 +310,7 @@ QString AlpmBackend::getPackageSize(const QString &pkgName)

if (pkg && strcmp(alpm_pkg_get_name(pkg),pkgName.toLatin1().constData())==0)
{
off_t pkgSize = alpm_pkg_get_size(pkg);
std::sprintf(size, "%ld", pkgSize);
pkgSize = alpm_pkg_get_size(pkg);
break;
}
}
Expand All @@ -321,7 +319,7 @@ QString AlpmBackend::getPackageSize(const QString &pkgName)
alpm_utils_free (alpm_utils); // this will free all alpm_pkgs but not the alpm_list
alpm_list_free (founds);

return QString::fromUtf8(size);
return pkgSize;
}

/*
Expand Down
2 changes: 1 addition & 1 deletion src/alpmbackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class AlpmBackend
static QStringList getUnrequiredList();
static QStringList getForeignList();
static QStringList getOutdatedList();
static QString getPackageSize(const QString &pkgName);
static double getPackageSize(const QString &pkgName);
//static PackageInfoData getPackageInfo(const QString &pkgName, bool isForeign);
};

Expand Down

0 comments on commit 8308707

Please sign in to comment.