mirror of
https://github.com/QuasarApp/CQtDeployer.git
synced 2025-05-03 21:19:34 +00:00
fix recursive moving
This commit is contained in:
parent
d7b48f3529
commit
041394eac5
@ -77,6 +77,7 @@ SOURCES += \
|
||||
qml.cpp \
|
||||
libinfo.cpp \
|
||||
qtdir.cpp \
|
||||
targetdata.cpp \
|
||||
targetinfo.cpp \
|
||||
zipcompresser.cpp
|
||||
|
||||
@ -114,6 +115,7 @@ HEADERS += \
|
||||
qml.h \
|
||||
libinfo.h \
|
||||
qtdir.h \
|
||||
targetdata.h \
|
||||
targetinfo.h \
|
||||
zipcompresser.h
|
||||
|
||||
|
@ -487,29 +487,32 @@ bool ConfigParser::initPackages() {
|
||||
|
||||
|
||||
for (auto& str: tar_packages_array) {
|
||||
auto pair = str.split(DeployCore::getSeparator(1));
|
||||
auto package = PathUtils::fullStripPath(pair.value(0, ""));
|
||||
auto paramsList = str.split(DeployCore::getSeparator(1));
|
||||
auto package = PathUtils::fullStripPath(paramsList.value(0, ""));
|
||||
|
||||
auto list = _config.getTargetsListByFilter(pair.value(1, ""));
|
||||
for (int i = 1; i < paramsList.size(); ++i) {
|
||||
auto targetPattern = paramsList.value(i);
|
||||
auto list = _config.getTargetsListByFilter(targetPattern);
|
||||
|
||||
if (!list.size()) {
|
||||
auto warning = QString("You create the %0 package with the %1 pattern, "
|
||||
"but no matches were found for this pattern. ").
|
||||
arg(package, pair.value(1, ""));
|
||||
QuasarAppUtils::Params::log(warning, QuasarAppUtils::Warning);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (auto it = list.begin(); it != list.end(); ++it) {
|
||||
if (!configuredTargets.contains(it.key())) {
|
||||
configuredTargets.insert(it.key());
|
||||
it.value()->setPackage(package);
|
||||
if (!list.size()) {
|
||||
auto warning = QString("You create the %0 package with the %1 pattern, "
|
||||
"but no matches were found for this pattern. ").
|
||||
arg(package, targetPattern);
|
||||
QuasarAppUtils::Params::log(warning, QuasarAppUtils::Warning);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (auto it = list.begin(); it != list.end(); ++it) {
|
||||
if (!configuredTargets.contains(it.key())) {
|
||||
configuredTargets.insert(it.key());
|
||||
it.value()->setPackage(package);
|
||||
}
|
||||
}
|
||||
|
||||
_config.packagesEdit().insert(package, DistroModule{package});
|
||||
}
|
||||
|
||||
_config.packagesEdit().insert(package, DistroModule{package});
|
||||
|
||||
if (pair.size() != 2) {
|
||||
if (paramsList.size() < 2) {
|
||||
defaultPackage = package;
|
||||
}
|
||||
}
|
||||
@ -773,7 +776,10 @@ bool ConfigParser::setTargets(const QStringList &value) {
|
||||
|
||||
if (targetInfo.isFile()) {
|
||||
|
||||
_config.targetsEdit().unite(createTarget(QDir::fromNativeSeparators(i)));
|
||||
auto target = createTarget(QDir::fromNativeSeparators(i));
|
||||
if (!_config.targetsEdit().contains(target.target)) {
|
||||
_config.targetsEdit().insert(target.target, target.targetInfo);
|
||||
}
|
||||
|
||||
isfillList = true;
|
||||
}
|
||||
@ -825,7 +831,7 @@ bool ConfigParser::setTargetsInDir(const QString &dir, bool recursive) {
|
||||
}
|
||||
|
||||
bool result = false;
|
||||
for (const auto &file : list) {
|
||||
for (const auto &file : qAsConst(list)) {
|
||||
|
||||
if (file.isDir()) {
|
||||
result |= setTargetsInDir(file.absoluteFilePath(), recursive);
|
||||
@ -838,9 +844,13 @@ bool ConfigParser::setTargetsInDir(const QString &dir, bool recursive) {
|
||||
if (sufix.isEmpty() || name.contains(".dll", Qt::CaseInsensitive) ||
|
||||
name.contains(".so", Qt::CaseInsensitive) || name.contains(".exe", Qt::CaseInsensitive)) {
|
||||
|
||||
result = true;
|
||||
|
||||
_config.targetsEdit().unite(createTarget(QDir::fromNativeSeparators(file.absoluteFilePath())));
|
||||
auto target = createTarget(QDir::fromNativeSeparators(file.absoluteFilePath()));
|
||||
if (!_config.targetsEdit().contains(target.target)) {
|
||||
_config.targetsEdit().insert(target.target, target.targetInfo);
|
||||
}
|
||||
|
||||
result = true;
|
||||
|
||||
}
|
||||
|
||||
@ -849,13 +859,13 @@ bool ConfigParser::setTargetsInDir(const QString &dir, bool recursive) {
|
||||
return result;
|
||||
}
|
||||
|
||||
QHash<QString, TargetInfo> ConfigParser::createTarget(const QString &target) {
|
||||
TargetData ConfigParser::createTarget(const QString &target) {
|
||||
TargetInfo libinfo;
|
||||
auto key = target;
|
||||
if (_scaner->fillLibInfo(libinfo, key)) {
|
||||
return {{libinfo.fullPath(), libinfo}};
|
||||
return {libinfo.fullPath(), libinfo};
|
||||
}
|
||||
return {{key, {}}};
|
||||
return {key, {}};
|
||||
}
|
||||
|
||||
QHash<QString, TargetInfo>
|
||||
@ -1455,6 +1465,16 @@ bool ConfigParser::smartMoveTargets() {
|
||||
bool result = true;
|
||||
for (auto i = _config.targets().cbegin(); i != _config.targets().cend(); ++i) {
|
||||
|
||||
if (!i.value().isValid()) {
|
||||
QuasarAppUtils::Params::log(QString("Interna error ocurred in %0. Target not inited.").arg(__FUNCTION__),
|
||||
QuasarAppUtils::Error);
|
||||
QuasarAppUtils::Params::log(QString("If you see this message please create a new issue"
|
||||
" about this problem on the official github page"
|
||||
" https://github.com/QuasarApp/CQtDeployer/issues/new/choose. "),
|
||||
QuasarAppUtils::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
QFileInfo target(i.key());
|
||||
|
||||
QString targetPath = _config.getTargetDir() + "/" + i.value().getPackage();
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "distrostruct.h"
|
||||
#include "envirement.h"
|
||||
#include "ignorerule.h"
|
||||
#include "targetdata.h"
|
||||
#include "targetinfo.h"
|
||||
|
||||
#include <QJsonObject>
|
||||
@ -100,7 +101,7 @@ private:
|
||||
void readKey(const QString &key, const QJsonObject &obj, const QString &confFileDir) const;
|
||||
void readString(const QString &key, const QString &val, const QString &confFileDir) const;
|
||||
|
||||
QHash<QString, TargetInfo> createTarget(const QString &target);
|
||||
TargetData createTarget(const QString &target);
|
||||
QHash<QString, TargetInfo> moveTarget(TargetInfo target, const QString &newLocation);
|
||||
|
||||
|
||||
|
@ -52,7 +52,7 @@ DistroModule DeployConfig::getDistroFromPackage(const QString &package) const {
|
||||
return _packages.value(package, DistroModule{package});
|
||||
}
|
||||
|
||||
QMultiHash<QString, TargetInfo> &DeployConfig::targetsEdit() {
|
||||
QHash<QString, TargetInfo> &DeployConfig::targetsEdit() {
|
||||
return _targets;
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ public:
|
||||
const QHash<QString, TargetInfo>& targets() const;
|
||||
const QHash<QString, DistroModule>& packages() const;
|
||||
|
||||
QMultiHash<QString, TargetInfo> &targetsEdit();
|
||||
QHash<QString, TargetInfo> &targetsEdit();
|
||||
QHash<QString, DistroModule>& packagesEdit();
|
||||
|
||||
/**
|
||||
@ -125,7 +125,7 @@ private:
|
||||
* key - path
|
||||
* value - create wrapper
|
||||
*/
|
||||
QMultiHash<QString, TargetInfo> _targets;
|
||||
QHash<QString, TargetInfo> _targets;
|
||||
|
||||
/**
|
||||
* @brief packages
|
||||
|
@ -352,6 +352,10 @@ bool FileManager::cp(const QString &from,
|
||||
bool FileManager::moveFolder(const QString &from, const QString &to, const QString& ignore) {
|
||||
QFileInfo info(from);
|
||||
|
||||
if (to.contains(from)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!info.exists())
|
||||
return false;
|
||||
|
||||
|
1
Deploy/targetdata.cpp
Normal file
1
Deploy/targetdata.cpp
Normal file
@ -0,0 +1 @@
|
||||
#include "targetdata.h"
|
22
Deploy/targetdata.h
Normal file
22
Deploy/targetdata.h
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 QuasarApp.
|
||||
* Distributed under the lgplv3 software license, see the accompanying
|
||||
* Everyone is permitted to copy and distribute verbatim copies
|
||||
* of this license document, but changing it is not allowed.
|
||||
*/
|
||||
|
||||
#ifndef TARGETDATA_H
|
||||
#define TARGETDATA_H
|
||||
|
||||
#include "targetinfo.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief The TargetData struct simple info structo about target.
|
||||
*/
|
||||
struct TargetData {
|
||||
QString target;
|
||||
TargetInfo targetInfo;
|
||||
};
|
||||
|
||||
#endif // TARGETDATA_H
|
Loading…
x
Reference in New Issue
Block a user