Skip to content
This repository has been archived by the owner on Sep 1, 2021. It is now read-only.

Commit

Permalink
Write image update date earlier (#159)
Browse files Browse the repository at this point in the history
Write updated date already when an image update is downloaded to prevent wrong image update dates
  • Loading branch information
Flohack74 authored and dobey committed May 31, 2019
1 parent 98ff8a1 commit cf10aa1
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
6 changes: 6 additions & 0 deletions debian/changelog
@@ -1,3 +1,9 @@
ubuntu-system-settings (0.4.3~0ubports1) xenial; urgency=medium

* Fix image updates not showing correct date (ubuntu-touch #1139)

-- Florian Leeber <florian@ubports.com> Tue, 28 May 2019 23:49:12 +0200

ubuntu-system-settings (0.4.3~0ubports0) xenial; urgency=medium

* Add settings for on-screen keyboard themes
Expand Down
7 changes: 6 additions & 1 deletion plugins/system-update/updatemodel.cpp
Expand Up @@ -394,7 +394,9 @@ void UpdateModel::setInstalled(const QString &id, const uint &rev)
if (!update.isNull()) {
update->setInstalled(true);
update->setState(Update::State::StateInstallFinished);
update->setUpdatedAt(QDateTime::currentDateTimeUtc());
if (update->kind() != Update::Kind::KindImage) {
update->setUpdatedAt(QDateTime::currentDateTimeUtc());
}
update->setDownloadId("");
update->setError("");
m_db->update(update);
Expand Down Expand Up @@ -443,6 +445,9 @@ void UpdateModel::setDownloaded(const QString &id, const uint &rev)
if (!update.isNull()) {
update->setError("");
update->setState(Update::State::StateDownloaded);
if (update->kind() == Update::Kind::KindImage) {
update->setUpdatedAt(QDateTime::currentDateTimeUtc());
}
m_db->update(update);
}
}
Expand Down
29 changes: 29 additions & 0 deletions tests/plugins/system-update/tst_updatemodel.cpp
Expand Up @@ -392,6 +392,35 @@ private slots:
QCOMPARE(update1->state(), Update::State::StateInstallFinished);
QCOMPARE(update1->downloadId(), QString(""));
}

//Test if the updated_at information is set after install only for click updates
void testClickUpdatedAtSetLate() {
auto update = createUpdate("id", 42);
update->setKind(Update::Kind::KindClick);
m_db->add(update);
m_model->setDownloaded(update->identifier(), update->revision());
auto update1 = m_db->get(update->identifier(), update->revision());
QCOMPARE(update1->updatedAt(), QDateTime());
m_model->setInstalled(update->identifier(), update->revision());
update1 = m_db->get(update->identifier(), update->revision());
QVERIFY(update1->updatedAt() != QDateTime());
}

//Test if the updated_at information is set after download already for image updates
void testImageUpdatedAtSetEarly()
{
auto update = createUpdate("id", 42);
update->setKind(Update::Kind::KindImage);
m_db->add(update);
m_model->setDownloaded(update->identifier(), update->revision());
auto update1 = m_db->get(update->identifier(), update->revision());
QDateTime firstDateTime = update1->updatedAt();
QVERIFY(firstDateTime != QDateTime());
m_model->setInstalled(update->identifier(), update->revision());
update1 = m_db->get(update->identifier(), update->revision());
QCOMPARE(update1->updatedAt(), firstDateTime);
}

void testSetError()
{
auto update = createUpdate("id", 42);
Expand Down

0 comments on commit cf10aa1

Please sign in to comment.