Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/common/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ namespace Utility {
constexpr bool isBSD(); // use with care, does not match OS X

OCSYNC_EXPORT QString platformName();

// AppImage helpers (Linux only, return empty/false elsewhere)
OCSYNC_EXPORT QString appImagePath();
OCSYNC_EXPORT bool isRunningInAppImage();
// crash helper for --debug
OCSYNC_EXPORT void crash();

Expand Down
10 changes: 10 additions & 0 deletions src/common/utility_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@

namespace OCC {

QString Utility::appImagePath()
{
return {};
}

bool Utility::isRunningInAppImage()
{
return false;
}

QVector<Utility::ProcessInfosForOpenFile> Utility::queryProcessInfosKeepingFileOpen(const QString &filePath)
{
Q_UNUSED(filePath)
Expand Down
22 changes: 15 additions & 7 deletions src/common/utility_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@

namespace OCC {

QString Utility::appImagePath()
{
return qEnvironmentVariable("APPIMAGE");
}

bool Utility::isRunningInAppImage()
{
const auto currentAppImagePath = appImagePath();
return !currentAppImagePath.isEmpty() && QFile::exists(currentAppImagePath);
}

QVector<Utility::ProcessInfosForOpenFile> Utility::queryProcessInfosKeepingFileOpen(const QString &filePath)
{
Q_UNUSED(filePath)
Expand Down Expand Up @@ -99,9 +110,9 @@ void Utility::setLaunchOnStartup(const QString &appName, const QString &guiName,
}
// When running inside an AppImage, we need to set the path to the
// AppImage instead of the path to the executable
const QString appImagePath = qEnvironmentVariable("APPIMAGE");
const bool runningInsideAppImage = !appImagePath.isNull() && QFile::exists(appImagePath);
const QString executablePath = runningInsideAppImage ? appImagePath : QCoreApplication::applicationFilePath();
const auto currentAppImagePath = appImagePath();
const auto runningInsideAppImage = isRunningInAppImage();
const auto executablePath = runningInsideAppImage ? currentAppImagePath : QCoreApplication::applicationFilePath();

QTextStream ts(&iniFile);
ts << QLatin1String("[Desktop Entry]\n")
Expand Down Expand Up @@ -134,10 +145,7 @@ QString Utility::getCurrentUserName()

void Utility::registerUriHandlerForLocalEditing()
{
const auto appImagePath = qEnvironmentVariable("APPIMAGE");
const auto runningInsideAppImage = !appImagePath.isNull() && QFile::exists(appImagePath);

if (!runningInsideAppImage) {
if (!isRunningInAppImage()) {
// only register x-scheme-handler if running inside appImage
return;
}
Expand Down
10 changes: 10 additions & 0 deletions src/common/utility_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ static const char runPathC[] = R"(HKEY_CURRENT_USER\Software\Microsoft\Windows\C

namespace OCC {

QString Utility::appImagePath()
{
return {};
}

bool Utility::isRunningInAppImage()
{
return false;
}

QVector<Utility::ProcessInfosForOpenFile> Utility::queryProcessInfosKeepingFileOpen(const QString &filePath)
{
QVector<ProcessInfosForOpenFile> results;
Expand Down
7 changes: 7 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,13 @@ IF(BUILD_UPDATER)
updater/updater.h
updater/updater.cpp
)
# Linux AppImage updater
if(UNIX AND NOT APPLE)
list(APPEND updater_SRCS
updater/appimageupdater.h
updater/appimageupdater.cpp
)
endif()
endif()

IF( APPLE )
Expand Down
Loading