mirror of
https://github.com/feather-wallet/feather.git
synced 2025-01-24 11:35:52 +00:00
fix macOS built-in updater
This commit is contained in:
parent
518fa831ae
commit
fc9452b513
6 changed files with 55 additions and 10 deletions
|
@ -32,7 +32,7 @@ if(DEBUG)
|
||||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(MONERO_HEAD "eba8ce661ce289df99f507225dbb1aaf58125e85")
|
set(MONERO_HEAD "bdd284b35d2e2c9c6ac733b4bc5ce8bd3b1162dd")
|
||||||
set(BUILD_GUI_DEPS ON)
|
set(BUILD_GUI_DEPS ON)
|
||||||
option(ARCH "Target architecture" "x86-64")
|
option(ARCH "Target architecture" "x86-64")
|
||||||
set(BUILD_64 ON)
|
set(BUILD_64 ON)
|
||||||
|
|
2
monero
2
monero
|
@ -1 +1 @@
|
||||||
Subproject commit d4257af2e7503fc6dc09fc704606230d353a0a02
|
Subproject commit bdd284b35d2e2c9c6ac733b4bc5ce8bd3b1162dd
|
|
@ -117,6 +117,11 @@ void UpdateDialog::onInstallUpdate() {
|
||||||
ui->btn_installUpdate->hide();
|
ui->btn_installUpdate->hide();
|
||||||
this->setStatus("Unzipping archive...");
|
this->setStatus("Unzipping archive...");
|
||||||
|
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
|
this->installUpdateMac();
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
zip_error_t err;
|
zip_error_t err;
|
||||||
zip_error_init(&err);
|
zip_error_init(&err);
|
||||||
|
|
||||||
|
@ -172,14 +177,7 @@ void UpdateDialog::onInstallUpdate() {
|
||||||
zip_fclose(zf);
|
zip_fclose(zf);
|
||||||
zip_close(zip_archive);
|
zip_close(zip_archive);
|
||||||
|
|
||||||
QString applicationPath = qgetenv("APPIMAGE");
|
QDir applicationDir(Utils::applicationPath());
|
||||||
if (!applicationPath.isEmpty()) {
|
|
||||||
applicationPath = QFileInfo(applicationPath).absoluteDir().path();
|
|
||||||
} else {
|
|
||||||
applicationPath = QCoreApplication::applicationDirPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
QDir applicationDir(applicationPath);
|
|
||||||
QString filePath = applicationDir.filePath(name);
|
QString filePath = applicationDir.filePath(name);
|
||||||
m_updatePath = filePath;
|
m_updatePath = filePath;
|
||||||
|
|
||||||
|
@ -206,6 +204,41 @@ void UpdateDialog::onInstallUpdate() {
|
||||||
ui->btn_restart->show();
|
ui->btn_restart->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdateDialog::installUpdateMac() {
|
||||||
|
QString appPath = Utils::applicationPath();
|
||||||
|
QDir appDir(appPath);
|
||||||
|
if (appPath.endsWith("Contents/MacOS")) {
|
||||||
|
appDir.cd("../../..");
|
||||||
|
}
|
||||||
|
QString appName = QString("feather-%1").arg(m_version);
|
||||||
|
QString zipName = QString("%1.zip").arg(appName);
|
||||||
|
QString fPath = appDir.filePath(zipName);
|
||||||
|
|
||||||
|
QFile file(fPath);
|
||||||
|
qDebug() << "Writing zip file to " << fPath;
|
||||||
|
if (!file.open(QIODevice::WriteOnly))
|
||||||
|
{
|
||||||
|
this->onInstallError(QString("Error: Could not write to application path: %1").arg(fPath));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (static_cast<size_t>(file.write(&m_updateZipArchive[0], m_updateZipArchive.size())) != m_updateZipArchive.size()) {
|
||||||
|
this->onInstallError("Error: Unable to write file");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QProcess unzip;
|
||||||
|
unzip.start("/usr/bin/unzip", {"-n", fPath, "-d", appDir.path()});
|
||||||
|
unzip.waitForFinished();
|
||||||
|
|
||||||
|
m_updatePath = QString("%1.app/Contents/MacOS/feather").arg(appDir.filePath(appName));
|
||||||
|
|
||||||
|
file.remove();
|
||||||
|
|
||||||
|
this->setStatus("Installation successful. Do you want to restart Feather now?");
|
||||||
|
ui->btn_restart->show();
|
||||||
|
}
|
||||||
|
|
||||||
void UpdateDialog::onInstallError(const QString &errMsg) {
|
void UpdateDialog::onInstallError(const QString &errMsg) {
|
||||||
this->setStatus(errMsg);
|
this->setStatus(errMsg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ signals:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setStatus(const QString &msg, bool success = false);
|
void setStatus(const QString &msg, bool success = false);
|
||||||
|
void installUpdateMac();
|
||||||
|
|
||||||
QScopedPointer<Ui::UpdateDialog> ui;
|
QScopedPointer<Ui::UpdateDialog> ui;
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,16 @@ QString defaultWalletDir() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString applicationPath() {
|
||||||
|
QString applicationPath = qgetenv("APPIMAGE");
|
||||||
|
if (!applicationPath.isEmpty()) {
|
||||||
|
applicationPath = QFileInfo(applicationPath).absoluteDir().path();
|
||||||
|
} else {
|
||||||
|
applicationPath = QCoreApplication::applicationDirPath();
|
||||||
|
}
|
||||||
|
return applicationPath;
|
||||||
|
}
|
||||||
|
|
||||||
bool validateJSON(const QByteArray &blob) {
|
bool validateJSON(const QByteArray &blob) {
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(blob);
|
QJsonDocument doc = QJsonDocument::fromJson(blob);
|
||||||
QString jsonString = doc.toJson(QJsonDocument::Indented);
|
QString jsonString = doc.toJson(QJsonDocument::Indented);
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace Utils
|
||||||
|
|
||||||
bool dirExists(const QString &path);
|
bool dirExists(const QString &path);
|
||||||
QString defaultWalletDir();
|
QString defaultWalletDir();
|
||||||
|
QString applicationPath();
|
||||||
|
|
||||||
bool validateJSON(const QByteArray &blob);
|
bool validateJSON(const QByteArray &blob);
|
||||||
bool readJsonFile(QIODevice &device, QSettings::SettingsMap &map);
|
bool readJsonFile(QIODevice &device, QSettings::SettingsMap &map);
|
||||||
|
|
Loading…
Reference in a new issue