Skip to content

Commit 37116df

Browse files
committed
Move fileInfo search into C++ code
1 parent 8319a89 commit 37116df

4 files changed

Lines changed: 10 additions & 13 deletions

File tree

application/screens/homescreen.qml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ Item {
9696
delegate: FlipperListDelegate {
9797
onUpdateRequested: {
9898
const channelName = "release";
99-
const firmwareType = "full_dfu";
10099
const latestVersion = firmwareUpdates.channel(channelName).latestVersion;
101100

102101
const messageObj = {
@@ -105,7 +104,7 @@ Item {
105104
};
106105

107106
confirmationDialog.openWithMessage(function() {
108-
downloader.downloadRemoteFile(device, latestVersion.fileInfo(firmwareType, device.target));
107+
downloader.downloadRemoteFile(device, latestVersion);
109108
}, messageObj);
110109
}
111110

application/screens/versionscreen.qml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,7 @@ Item {
6060
delegate: VersionListDelegate {
6161
onInstallRequested: {
6262
screen.homeRequested();
63-
64-
const firmwareType = "full_dfu";
65-
const fileInfo = versionInfo.fileInfo(firmwareType, device.target);
66-
downloader.downloadRemoteFile(screen.device, fileInfo);
63+
downloader.downloadRemoteFile(screen.device, versionInfo);
6764
}
6865

6966
onChangelogRequested: {

backend/firmwaredownloader.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,17 @@ void FirmwareDownloader::downloadLocalFile(FlipperZero *device, const QString &f
2828
enqueueOperation(new Flipper::Zero::FirmwareDownloadOperation(device, file));
2929
}
3030

31-
void FirmwareDownloader::downloadRemoteFile(FlipperZero *device, const Updates::FileInfo &fileInfo)
31+
void FirmwareDownloader::downloadRemoteFile(FlipperZero *device, const Flipper::Updates::VersionInfo &versionInfo)
3232
{
3333
// TODO: Local cache on hard disk?
34+
const auto fileInfo = versionInfo.fileInfo(QStringLiteral("full_dfu"), device->target());
35+
3436
auto *fetcher = new RemoteFileFetcher(this);
37+
auto *buf = new QBuffer(this);
3538

36-
connect(fetcher, &RemoteFileFetcher::finished, this, [=](const QByteArray &data) {
37-
auto *buf = new QBuffer(this);
39+
check_return_void(buf->open(QIODevice::ReadWrite), "Failed to create intermediate buffer.");
3840

39-
buf->open(QIODevice::ReadWrite);
40-
buf->write(data);
41+
connect(fetcher, &RemoteFileFetcher::finished, this, [=]() {
4142
buf->seek(0);
4243
buf->close();
4344

@@ -47,7 +48,7 @@ void FirmwareDownloader::downloadRemoteFile(FlipperZero *device, const Updates::
4748
});
4849

4950
device->setStatusMessage(tr("Fetching the update file..."));
50-
fetcher->fetch(fileInfo);
51+
fetcher->fetch(fileInfo, buf);
5152
}
5253

5354
void FirmwareDownloader::downloadLocalFUS(FlipperZero *device, const QString &filePath)

backend/firmwaredownloader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class FirmwareDownloader : public QObject
2626

2727
public slots:
2828
void downloadLocalFile(Flipper::FlipperZero *device, const QString &filePath);
29-
void downloadRemoteFile(Flipper::FlipperZero *device, const Flipper::Updates::FileInfo &fileInfo);
29+
void downloadRemoteFile(Flipper::FlipperZero *device, const Flipper::Updates::VersionInfo &versionInfo);
3030

3131
void downloadLocalFUS(Flipper::FlipperZero *device, const QString &filePath);
3232
void downloadLocalWirelessStack(Flipper::FlipperZero *device, const QString &filePath);

0 commit comments

Comments
 (0)