mirror of
https://github.com/tnodir/fort
synced 2024-11-15 06:55:54 +00:00
UI: TaskInfoUpdateChecker: Save download size
This commit is contained in:
parent
b6f6f6e671
commit
5dddc0cb7e
@ -71,10 +71,14 @@ void AutoUpdateManager::clearUpdateDir()
|
||||
|
||||
bool AutoUpdateManager::runInstaller()
|
||||
{
|
||||
const QByteArray fileData = downloader()->takeBuffer();
|
||||
if (fileData.size() != m_taskInfo->downloadSize())
|
||||
return false;
|
||||
|
||||
const QString fileName = QUrl(downloader()->url()).fileName();
|
||||
const QString exePath = m_updatePath + fileName;
|
||||
|
||||
if (!FileUtil::writeFileData(exePath, downloader()->takeBuffer()))
|
||||
if (!FileUtil::writeFileData(exePath, fileData))
|
||||
return false;
|
||||
|
||||
QStringList args;
|
||||
|
@ -13,7 +13,7 @@ namespace {
|
||||
|
||||
const QLoggingCategory LC("task.updateChecker");
|
||||
|
||||
constexpr int TASK_INFO_VERSION = 2;
|
||||
constexpr int TASK_INFO_VERSION = 3;
|
||||
|
||||
}
|
||||
|
||||
@ -37,8 +37,8 @@ QByteArray TaskInfoUpdateChecker::data() const
|
||||
// Store data
|
||||
const quint16 infoVersion = TASK_INFO_VERSION;
|
||||
|
||||
stream << infoVersion << QString::fromLatin1(APP_VERSION_STR) << m_version << m_downloadUrl
|
||||
<< m_releaseText;
|
||||
stream << infoVersion << QString::fromLatin1(APP_VERSION_STR) << m_version << m_releaseText
|
||||
<< m_downloadUrl << m_downloadSize;
|
||||
|
||||
return data;
|
||||
}
|
||||
@ -66,7 +66,7 @@ void TaskInfoUpdateChecker::setData(const QByteArray &data)
|
||||
if (appVersion != APP_VERSION_STR)
|
||||
return; // app upgraded
|
||||
|
||||
stream >> m_version >> m_downloadUrl >> m_releaseText;
|
||||
stream >> m_version >> m_releaseText >> m_downloadUrl >> m_downloadSize;
|
||||
|
||||
emitAppVersionUpdated();
|
||||
}
|
||||
@ -91,8 +91,9 @@ bool TaskInfoUpdateChecker::processResult(bool success)
|
||||
}
|
||||
|
||||
m_version = worker->version();
|
||||
m_downloadUrl = worker->downloadUrl();
|
||||
m_releaseText = worker->releaseText();
|
||||
m_downloadUrl = worker->downloadUrl();
|
||||
m_downloadSize = worker->downloadSize();
|
||||
|
||||
emitAppVersionUpdated();
|
||||
|
||||
|
@ -14,8 +14,9 @@ public:
|
||||
|
||||
bool isNewVersion() const;
|
||||
QString version() const { return m_version; }
|
||||
QString downloadUrl() const { return m_downloadUrl; }
|
||||
QString releaseText() const { return m_releaseText; }
|
||||
QString downloadUrl() const { return m_downloadUrl; }
|
||||
int downloadSize() const { return m_downloadSize; }
|
||||
|
||||
QByteArray data() const override;
|
||||
void setData(const QByteArray &data) override;
|
||||
@ -30,8 +31,10 @@ private:
|
||||
|
||||
private:
|
||||
QString m_version;
|
||||
QString m_downloadUrl;
|
||||
QString m_releaseText;
|
||||
|
||||
QString m_downloadUrl;
|
||||
int m_downloadSize = 0;
|
||||
};
|
||||
|
||||
#endif // TASKINFOUPDATECHECKER_H
|
||||
|
@ -12,6 +12,7 @@ public:
|
||||
|
||||
QString version() const { return m_version; }
|
||||
QString downloadUrl() const { return m_downloadUrl; }
|
||||
int downloadSize() const { return m_downloadSize; }
|
||||
|
||||
QString releaseText() const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user