Add handling of alwaysDownloadConfig and alwaysDownloadDC.

Not tested and commnetd out.
This commit is contained in:
Gerhard Hoffmann 2023-11-21 09:54:57 +01:00
parent 1ad13d9a8a
commit 89b639c0ed

View File

@ -116,6 +116,8 @@ Worker::Worker(int customerNr,
QString pluginName, QString pluginName,
QString workingDirectory, QString workingDirectory,
bool noUpdatePsaHardware, bool noUpdatePsaHardware,
bool alwaysDownloadConfig,
bool alwaysDownloadDC,
bool dryRun, bool dryRun,
QObject *parent, QObject *parent,
char const *serialInterface, char const *serialInterface,
@ -131,6 +133,8 @@ Worker::Worker(int customerNr,
, m_customerRepositoryPath(QString("%1/%2.git").arg(repositoryUrl).arg(m_customerNrStr)) , m_customerRepositoryPath(QString("%1/%2.git").arg(repositoryUrl).arg(m_customerNrStr))
, m_customerRepository(QDir::cleanPath(m_workingDirectory + QDir::separator() + m_customerNrStr)) , m_customerRepository(QDir::cleanPath(m_workingDirectory + QDir::separator() + m_customerNrStr))
, m_noUpdatePsaHardware(noUpdatePsaHardware) , m_noUpdatePsaHardware(noUpdatePsaHardware)
, m_alwaysDownloadConfig(alwaysDownloadConfig)
, m_alwaysDownloadDC(alwaysDownloadDC)
, m_dryRun(dryRun) , m_dryRun(dryRun)
, m_parent(parent) , m_parent(parent)
, m_serialInterface(serialInterface) , m_serialInterface(serialInterface)
@ -638,6 +642,39 @@ bool Worker::filesToUpdate() {
// always execute contents of opkg_commands-file // always execute contents of opkg_commands-file
m_filesToUpdate << "etc/psa_update/opkg_commands"; m_filesToUpdate << "etc/psa_update/opkg_commands";
if (m_alwaysDownloadConfig) {
#if 0
QStringList lst(QString("m_alwaysDownloadConfig NOT TESTED"));
CONSOLE(lst) << UPDATE_STEP::UPDATE_REPOSITORY;
// always download all json-config files, even if none of them have been
// changed in the git repository. useful for first installation.
QDir dir(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/psa_config"));
if (dir.exists()) {
QStringList jsons = dir.entryList(QStringList() << "DC2C*.json", QDir::Files);
if (!jsons.isEmpty()) {
m_filesToUpdate << jsons;
}
}
#endif
}
if (m_alwaysDownloadDC) {
#if 0
QStringList lst(QString("m_alwaysDownloadDC NOT TESTED"));
CONSOLE(lst) << UPDATE_STEP::UPDATE_REPOSITORY;
// always download the last dc-binary, even if not changed in the
// git repository. useful for first installation.
QDir dir(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/psa_update"));
if (dir.exists()) {
QStringList dc = dir.entryList(QStringList() << "dc2c*.bin", QDir::Files,
QDir::SortFlag::Time | QDir::SortFlag::Reversed);
if (!dc.isEmpty()) {
m_filesToUpdate << dc.first();
}
}
#endif
}
if (std::optional<QString> changes = m_gc.gitPull()) { if (std::optional<QString> changes = m_gc.gitPull()) {
if (!changes.value().contains("Already up to date")) { if (!changes.value().contains("Already up to date")) {
if (std::optional<QStringList> changedFileNames = m_gc.gitDiff(changes.value())) { if (std::optional<QStringList> changedFileNames = m_gc.gitDiff(changes.value())) {
@ -652,7 +689,6 @@ bool Worker::filesToUpdate() {
return false; return false;
} }
return true; return true;
} }