Skip to content

Commit 1febd01

Browse files
DanielSvobodaXcedf
authored andcommitted
Fix AutoUpdate Issue with Non-Latin Usernames/Directories (shadps4-emu#1853)
* Fix updater for non-Latin user directories * QStandardPaths
1 parent 99c5111 commit 1febd01

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/qt_gui/check_update.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <QNetworkRequest>
1616
#include <QProcess>
1717
#include <QPushButton>
18+
#include <QStandardPaths>
1819
#include <QString>
1920
#include <QStringList>
2021
#include <QTextEdit>
@@ -348,7 +349,9 @@ void CheckUpdate::DownloadUpdate(const QString& url) {
348349
QString userPath;
349350
Common::FS::PathToQString(userPath, Common::FS::GetUserPath(Common::FS::PathType::UserDir));
350351
#ifdef Q_OS_WIN
351-
QString tempDownloadPath = QString(getenv("LOCALAPPDATA")) + "/Temp/temp_download_update";
352+
QString tempDownloadPath =
353+
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) +
354+
"/Temp/temp_download_update";
352355
#else
353356
QString tempDownloadPath = userPath + "/temp_download_update";
354357
#endif
@@ -397,10 +400,11 @@ void CheckUpdate::Install() {
397400
QString processCommand;
398401

399402
#ifdef Q_OS_WIN
400-
// On windows, overwrite tempDirPath with AppData/Local/Temp folder
403+
// On windows, overwrite tempDirPath with AppData/Roaming/shadps4/Temp folder
401404
// due to PowerShell Expand-Archive not being able to handle correctly
402405
// paths in square brackets (ie: ./[shadps4])
403-
tempDirPath = QString(getenv("LOCALAPPDATA")) + "/Temp/temp_download_update";
406+
tempDirPath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) +
407+
"/Temp/temp_download_update";
404408

405409
// Windows Batch Script
406410
scriptFileName = tempDirPath + "/update.ps1";
@@ -536,6 +540,7 @@ void CheckUpdate::Install() {
536540
QFile scriptFile(scriptFileName);
537541
if (scriptFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
538542
QTextStream out(&scriptFile);
543+
scriptFile.write("\xEF\xBB\xBF");
539544
#ifdef Q_OS_WIN
540545
out << scriptContent.arg(binaryStartingUpdate).arg(tempDirPath).arg(rootPath);
541546
#endif

0 commit comments

Comments
 (0)