Skip to content

Commit

Permalink
Fix sizes, include also download size
Browse files Browse the repository at this point in the history
  • Loading branch information
alvieboy committed Mar 29, 2014
1 parent 1c3b68f commit 09c923f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
4 changes: 3 additions & 1 deletion manager/ArduinoUpdateManager/mainwindow.cpp
Expand Up @@ -110,7 +110,9 @@ void MainWindow::onSetBranchLeaf()
QModelIndex index = ui->treeView->currentIndex();
QVariant v = m_releaseModel->data(index);

qDebug()<<"Set branch"<<getCurrentBranch()<<"leaf to"<< v.toString();
qDebug()<<"Set branch"<<getCurrentBranch()<<"leaf to"<< v.toString();

manager.setBranchLeaf(currentOS(),getCurrentBranch(),v.toString());
}

void MainWindow::contextualMenu(const QPoint &p)
Expand Down
42 changes: 41 additions & 1 deletion manager/ArduinoUpdateManager/manager.cpp
Expand Up @@ -232,6 +232,15 @@ const ReleaseFile &Manager::getParentFile( const OSReleaseList &list, const OSRe
return prelease.getFile(file.name);
}

QString Manager::getDownloadSize(const QString &sha)
{
QString target = m_deployPath + QDir::separator() + "blobs" + QDir::separator() + sha + ".gz";

QFile f(target);

return QString::number(f.size());
}

void Manager::createOSList(const QString &os, QFile &file)
{
QDomDocument d;
Expand Down Expand Up @@ -269,6 +278,7 @@ void Manager::createOSList(const QString &os, QFile &file)
/* Add resources and releases */

QHash<SHA,uint> shaMap;
QHash<QString,bool> filesMap;

foreach (const OSRelease &r, getReleaseList(os)) {
uint thisId;
Expand Down Expand Up @@ -296,6 +306,7 @@ void Manager::createOSList(const QString &os, QFile &file)
rs.setAttribute("id",rsid);
rs.setAttribute("sha",QString(f.sha.toHex()));
rs.setAttribute("size", QString::number(f.size));
rs.setAttribute("dsize", getDownloadSize(f.sha.toHex()));
resources.appendChild(rs);
} else {
thisId = shaMap[f.sha];
Expand All @@ -306,10 +317,22 @@ void Manager::createOSList(const QString &os, QFile &file)
if (f.exec)
file.setAttribute("exec", "yes");
release.appendChild(file);
}
}
filesMap[f.name]=true;
}
/* Now, iterate through all parent files. If not present any more,
deprecate them. */
if (r.parent.size()) {
foreach (const ReleaseFile &f, getReleaseByName(r.parent,getReleaseList(os)).files) {
if (filesMap.find(f.name)==filesMap.end()) {
QDomElement file = d.createElement("File");
file.setAttribute("target", f.name);
file.setAttribute("rsid", "-1");
release.appendChild(file);
qDebug()<<f.name<<"deprecated.";
}
}
}
}


Expand Down Expand Up @@ -347,6 +370,23 @@ const OSBranchList &Manager::getBranchList(const QString &os) const
return it.value();
}

void Manager::setBranchLeaf(const QString &os, const QString &branch, const QString &leaf)
{
AllBranchList::iterator it = m_branchList.find(os);
if (it!=m_branchList.end()) {
OSBranchList::iterator i;

for ( i=it->begin(); i!=it->end(); i++ ) {
if (i->name==branch) {
i->leaf=leaf;
break;
}
}
}
}



void Manager::setParentRelease(const QString &os, const QString &release, const QString &parent)
{
OSRelease &r = getReleaseByName(release, m_releaseList[os]);
Expand Down
2 changes: 2 additions & 0 deletions manager/ArduinoUpdateManager/manager.h
Expand Up @@ -58,6 +58,7 @@ class Manager
void addRelease(const QString &os, const OSRelease &release);
void setParentRelease(const QString &os, const QString &release, const QString &parent);

void setBranchLeaf(const QString &os, const QString &branch, const QString &leaf);
void reset();
void addOS(const QString &os);
void setDeployPath(const QString&path);
Expand All @@ -72,6 +73,7 @@ class Manager
OSRelease &getReleaseByName(const QString &name, OSReleaseList &list);

const ReleaseFile &getParentFile( const OSReleaseList &list, const OSRelease &release, const ReleaseFile &file );
QString getDownloadSize(const QString &sha);


private:
Expand Down

0 comments on commit 09c923f

Please sign in to comment.