mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
Bootstrap file name encapsulated
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "blackcore/data/globalsetup.h"
|
||||
#include "blackcore/application.h"
|
||||
#include "blackmisc/json.h"
|
||||
#include "blackmisc/directoryutils.h"
|
||||
#include "blackmisc/network/server.h"
|
||||
#include "blackmisc/network/user.h"
|
||||
#include "blackmisc/stringutils.h"
|
||||
@@ -90,7 +91,7 @@ namespace BlackCore
|
||||
|
||||
CUrlList CGlobalSetup::getSwiftBootstrapFileUrls() const
|
||||
{
|
||||
return getSwiftSharedUrls().withAppendedPath(CGlobalSetup::schemaVersionString() + "/bootstrap/bootstrap.json");
|
||||
return getSwiftSharedUrls().withAppendedPath(CGlobalSetup::schemaVersionString() + "/bootstrap/" + CDirectoryUtils::bootstrapFileName());
|
||||
}
|
||||
|
||||
CUrlList CGlobalSetup::getSwiftUpdateInfoFileUrls() const
|
||||
@@ -172,23 +173,23 @@ namespace BlackCore
|
||||
{
|
||||
if (candidate.isEmpty()) return ""; // not possible
|
||||
static const QString version(QString(CGlobalSetup::schemaVersionString()).append("/"));
|
||||
if (candidate.endsWith("bootstrap.json")) { return candidate; }
|
||||
if (candidate.endsWith(CDirectoryUtils::bootstrapFileName())) { return candidate; }
|
||||
CUrl url(candidate);
|
||||
if (candidate.contains("/bootstrap"))
|
||||
{
|
||||
url.appendPath("bootstrap.json");
|
||||
url.appendPath(CDirectoryUtils::bootstrapFileName());
|
||||
}
|
||||
else if (candidate.endsWith(CGlobalSetup::schemaVersionString()) || candidate.endsWith(version))
|
||||
{
|
||||
url.appendPath("/bootstrap/bootstrap.json");
|
||||
url.appendPath("/bootstrap/" + CDirectoryUtils::bootstrapFileName());
|
||||
}
|
||||
else if (candidate.endsWith("shared") || candidate.endsWith("shared/"))
|
||||
{
|
||||
url.appendPath(CGlobalSetup::schemaVersionString() + "/bootstrap/bootstrap.json");
|
||||
url.appendPath(CGlobalSetup::schemaVersionString() + "/bootstrap/" + CDirectoryUtils::bootstrapFileName());
|
||||
}
|
||||
else
|
||||
{
|
||||
url.appendPath("shared/" + CGlobalSetup::schemaVersionString() + "/bootstrap/bootstrap.json");
|
||||
url.appendPath("shared/" + CGlobalSetup::schemaVersionString() + "/bootstrap/" + CDirectoryUtils::bootstrapFileName());
|
||||
}
|
||||
return url.getFullUrl();
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ namespace BlackCore
|
||||
if (dir.isEmpty()) { return CStatusMessage(this).error("Empty shared directory '%1' for bootstrap file") << dir; }
|
||||
|
||||
// no version for local files, as those come with the current code
|
||||
fn = CFileUtils::appendFilePaths(dir, "bootstrap/bootstrap.json");
|
||||
fn = CFileUtils::appendFilePaths(dir, "bootstrap/" + CDirectoryUtils::bootstrapFileName());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -178,11 +178,17 @@ namespace BlackMisc
|
||||
return s;
|
||||
}
|
||||
|
||||
const QString &CDirectoryUtils::bootstrapFileName()
|
||||
{
|
||||
static const QString n("bootstrap.json");
|
||||
return n;
|
||||
}
|
||||
|
||||
const QString getBootstrapResourceFileImpl()
|
||||
{
|
||||
const QString d(CDirectoryUtils::shareDirectory());
|
||||
if (d.isEmpty()) { return ""; }
|
||||
const QFile file(QDir::cleanPath(d + QDir::separator() + "shared/bootstrap/bootstrap.json"));
|
||||
const QFile file(QDir::cleanPath(d + QDir::separator() + "shared/bootstrap/" + CDirectoryUtils::bootstrapFileName()));
|
||||
Q_ASSERT_X(file.exists(), Q_FUNC_INFO, "missing bootstrap file");
|
||||
return QFileInfo(file).absoluteFilePath();
|
||||
}
|
||||
|
||||
@@ -65,6 +65,9 @@ namespace BlackMisc
|
||||
//! \remark share not shared (do no mix)
|
||||
static const QString &shareDirectory();
|
||||
|
||||
//! Bootstrap file name
|
||||
static const QString &bootstrapFileName();
|
||||
|
||||
//! Bootstrap resource file path
|
||||
static const QString &bootstrapResourceFilePath();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user