Skip to content

Commit

Permalink
Update large files handle
Browse files Browse the repository at this point in the history
  • Loading branch information
Wano-k committed Nov 23, 2021
1 parent c3cc233 commit 000d0e1
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 13 deletions.
51 changes: 38 additions & 13 deletions engineupdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
#include <QMessageBox>
#include <QTimer>

const QString EngineUpdater::VERSION = "2.8";
const QString EngineUpdater::VERSION = "2.9";
const QString EngineUpdater::ELECTRON_VERSION = "1.5.3";
const QString EngineUpdater::LARGE_FILES_UPDATE_VERSION = "1.9.2";
const QString EngineUpdater::jsonFiles = "files";
const QString EngineUpdater::jsonSource = "source";
const QString EngineUpdater::jsonTarget = "target";
Expand All @@ -45,6 +46,7 @@ const QString EngineUpdater::jsonMac = "m";
const QString EngineUpdater::jsonOnlyFiles = "onlyFiles";
const QString EngineUpdater::jsonSymLink = "sl";
const QString EngineUpdater::jsonExe = "exe";
const QString EngineUpdater::jsonLarge = "large";
const QString EngineUpdater::jsonAdd = "add";
const QString EngineUpdater::jsonRemove = "remove";
const QString EngineUpdater::jsonReplace = "replace";
Expand Down Expand Up @@ -166,8 +168,10 @@ void EngineUpdater::writeTrees() {
objEngineExe["linux"] = objTemp;
getJSONExeEngine(objTemp, "osx");
objEngineExe["osx"] = objTemp;
getJSONExeGame(objTemp, "win32");
objGameExe["win32"] = objTemp;
getJSONExeGame(objTemp, "winx64");
objGameExe["winx64"] = objTemp;
getJSONExeGame(objTemp, "winx86");
objGameExe["winx86"] = objTemp;
getJSONExeGame(objTemp, "linux");
objGameExe["linux"] = objTemp;
getJSONExeGame(objTemp, "osx");
Expand Down Expand Up @@ -217,32 +221,46 @@ void EngineUpdater::getTree(QJsonObject& objTree, QString localUrl,
QString currentPath = Common::pathCombine(path, name);
QString currentTarget = Common::pathCombine(targetUrl, name);
QJsonObject obj;
bool test = true;
QString large = "";
if (directories.fileInfo().isDir() && !directories.fileInfo().isSymLink())
{
getTree(obj, localUrl, currentPath, currentTarget, repo);
} else {
if (directories.fileName() == "Electron Framework" && !directories.fileInfo().isSymLink())
{
test = false;
large = "Electron Framework";
}
getJSONFile(obj, currentPath, currentTarget, repo, directories
.fileInfo().isSymLink(), directories.fileInfo().isDir());
}
if (test && (path != "Game/linux" || (path == "Game/linux" &&
directories.fileName() != "Game")))
if (!large.isEmpty() || (path == "Game/linux" && directories.fileName() == "Game")
|| (path == "Game/winx64" && directories.fileName() == "Game.exe") ||
(path == "Game/winx86" && directories.fileName() == "Game.exe"))
{
tabFiles.append(obj);
if (!large.isEmpty())
{
obj[jsonLarge] = large;
} else if (path == "Game/linux")
{
obj[jsonLarge] = "Game";
} else if (path == "Game/winx64")
{
obj[jsonLarge] = "Game.exe";
} else if (path == "Game/winx86")
{
obj[jsonLarge] = "Game.exe";
}
}
tabFiles.append(obj);
}

getJSONDir(objTree, tabFiles, targetUrl);
}

// -------------------------------------------------------

void EngineUpdater::getJSONFile(QJsonObject& obj, QString source,
QString target, QString repo, bool link, bool isDir)
void EngineUpdater::getJSONFile(QJsonObject& obj, QString source, QString target,
QString repo, bool link, bool isDir)
{
obj[jsonSource] = source;
obj[jsonTarget] = target;
Expand Down Expand Up @@ -293,7 +311,7 @@ void EngineUpdater::getJSONExeEngine(QJsonObject& obj, QString os) {
void EngineUpdater::getJSONExeGame(QJsonObject& obj, QString os) {
QString exe;

if (os == "win32")
if (os == "winx64" || os == "winx86")
exe = "Game.exe";
else if (os == "linux")
exe = "Game";
Expand Down Expand Up @@ -438,7 +456,12 @@ bool EngineUpdater::downloadFile(EngineUpdateFileKind action,
bool tree = obj.contains(jsonTree);
bool exe = obj.contains(jsonExe);
bool link = obj.contains(jsonSymLink);

QString large = obj[jsonLarge].toString();
if (!large.isEmpty())
{
this->downloadLargeFile(m_largeVersion, large, target);
return true;
}
if (tree) {
QJsonObject objTree = m_document[source].toObject();
if (!downloadFolder(action, objTree, version))
Expand Down Expand Up @@ -700,6 +723,7 @@ bool EngineUpdater::readDocumentVersion() {
m_lastVersion = doc["lastVersion"].toString();
m_updaterVersion = doc["uversion"].toString();
m_versions = doc["versions"].toArray();
m_largeVersion = doc["largeVersion"].toString();

return true;
}
Expand Down Expand Up @@ -1013,7 +1037,8 @@ void EngineUpdater::downloadTranslations(QString version)

void EngineUpdater::downloadLargeFiles(QString version)
{
if (Common::versionDifferent(version, EngineUpdater::ELECTRON_VERSION) != -1)
if (Common::versionDifferent(version, EngineUpdater::ELECTRON_VERSION) != -1 &&
Common::versionDifferent(version, EngineUpdater::LARGE_FILES_UPDATE_VERSION) == -1)
{
this->downloadLargeFile(EngineUpdater::ELECTRON_VERSION, "Game.exe", "Engine/Content/win32/Game.exe");
this->downloadLargeFile(EngineUpdater::ELECTRON_VERSION, "Game", "Engine/Content/linux/Game");
Expand Down
3 changes: 3 additions & 0 deletions engineupdater.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class EngineUpdater : public QObject

static const QString VERSION;
static const QString ELECTRON_VERSION;
static const QString LARGE_FILES_UPDATE_VERSION;
static const QString jsonFiles;
static const QString jsonSource;
static const QString jsonTarget;
Expand All @@ -60,6 +61,7 @@ class EngineUpdater : public QObject
static const QString jsonOnlyFiles;
static const QString jsonSymLink;
static const QString jsonExe;
static const QString jsonLarge;
static const QString jsonAdd;
static const QString jsonReplace;
static const QString jsonRemove;
Expand Down Expand Up @@ -145,6 +147,7 @@ class EngineUpdater : public QObject
QString m_currentVersion;
QString m_lastVersion;
QString m_updaterVersion;
QString m_largeVersion;
QString m_messageError;
QString m_focusProgress;
int m_countFiles;
Expand Down

0 comments on commit 000d0e1

Please sign in to comment.