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