Skip to content

Commit

Permalink
Fix downloaded file renaming on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
gsurkov committed Aug 24, 2021
1 parent b6dd6eb commit 1889756
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
12 changes: 8 additions & 4 deletions application/appupdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,13 @@ void AppUpdater::installUpdate(const Flipper::Updates::VersionInfo &versionInfo)
emit downloadFinished();

// IMPORTANT -- The file is closed automatically before renaming (https://doc.qt.io/qt-5/qfile.html#rename)
if(file->rename(fileName)) {
error_msg("Failed to rename .part file to its proper name");
if(!file->rename(filePath)) {
error_msg("Failed to rename .part file");
emit errorOccured();

file->remove();
cleanup();
return;
}

info_msg("Application update download has finished.");
Expand Down Expand Up @@ -113,10 +117,10 @@ void AppUpdater::setProgress(double progress)

bool AppUpdater::performUpdate(const QString &path)
{
#if defined(Q_OS_WINDOWS) || defined(Q_OS_LINUX)
#if defined(Q_OS_LINUX)
const auto info = QFileInfo(path);
return QProcess::startDetached(info.fileName(), {}, info.absoluteDir().absolutePath());
#elif defined(Q_OS_MAC)
#elif defined(Q_OS_WINDOWS) || defined(Q_OS_MAC)
return QDesktopServices::openUrl(path);
#endif
}
8 changes: 7 additions & 1 deletion application/screens/homescreen.qml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Item {

text: {
const currentVersion = app.version;
const currentCommit = app.commit;
const currentCommit = "deadbaba";//app.commit;

const msg = "%1 %2 %3".arg(app.name).arg(qsTr("Version")).arg(currentVersion);

Expand Down Expand Up @@ -228,6 +228,12 @@ Item {
app.updater.progressChanged.connect(function() {
versionLabel.text = qsTr("Downloading application update... %1%").arg(Math.floor(app.updater.progress));
});

app.updater.errorOccured.connect(function() {
versionLabel.text = qsTr("Update failed");
versionLabel.color = "#700";
versionLabel.font.bold = true;
});
}
}
}

0 comments on commit 1889756

Please sign in to comment.