mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-05-01 07:04:32 +02:00
fix: file filtering on modpack export
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
f086233186
commit
147159be2c
@ -269,9 +269,9 @@ bool FileIgnoreProxy::ignoreFile(QFileInfo fileInfo) const
|
|||||||
return m_ignoreFiles.contains(fileInfo.fileName()) || m_ignoreFilePaths.covers(relPath(fileInfo.absoluteFilePath()));
|
return m_ignoreFiles.contains(fileInfo.fileName()) || m_ignoreFilePaths.covers(relPath(fileInfo.absoluteFilePath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileIgnoreProxy::filterFile(const QString& fileName) const
|
bool FileIgnoreProxy::filterFile(const QFileInfo& file) const
|
||||||
{
|
{
|
||||||
return m_blocked.covers(fileName) || ignoreFile(QFileInfo(QDir(m_root), fileName));
|
return m_blocked.covers(relPath(file.absoluteFilePath())) || ignoreFile(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileIgnoreProxy::loadBlockedPathsFromFile(const QString& fileName)
|
void FileIgnoreProxy::loadBlockedPathsFromFile(const QString& fileName)
|
||||||
|
@ -69,7 +69,7 @@ class FileIgnoreProxy : public QSortFilterProxyModel {
|
|||||||
// list of relative paths that need to be removed completely from model
|
// list of relative paths that need to be removed completely from model
|
||||||
inline SeparatorPrefixTree<'/'>& ignoreFilesWithPath() { return m_ignoreFilePaths; }
|
inline SeparatorPrefixTree<'/'>& ignoreFilesWithPath() { return m_ignoreFilePaths; }
|
||||||
|
|
||||||
bool filterFile(const QString& fileName) const;
|
bool filterFile(const QFileInfo& fileName) const;
|
||||||
|
|
||||||
void loadBlockedPathsFromFile(const QString& fileName);
|
void loadBlockedPathsFromFile(const QString& fileName);
|
||||||
|
|
||||||
|
@ -418,7 +418,7 @@ bool extractFile(QString fileCompressed, QString file, QString target)
|
|||||||
return extractRelFile(&zip, file, target);
|
return extractRelFile(&zip, file, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool collectFileListRecursively(const QString& rootDir, const QString& subDir, QFileInfoList* files, FilterFunction excludeFilter)
|
bool collectFileListRecursively(const QString& rootDir, const QString& subDir, QFileInfoList* files, FilterFileFunction excludeFilter)
|
||||||
{
|
{
|
||||||
QDir rootDirectory(rootDir);
|
QDir rootDirectory(rootDir);
|
||||||
if (!rootDirectory.exists())
|
if (!rootDirectory.exists())
|
||||||
@ -443,8 +443,8 @@ bool collectFileListRecursively(const QString& rootDir, const QString& subDir, Q
|
|||||||
// collect files
|
// collect files
|
||||||
entries = directory.entryInfoList(QDir::Files);
|
entries = directory.entryInfoList(QDir::Files);
|
||||||
for (const auto& e : entries) {
|
for (const auto& e : entries) {
|
||||||
|
if (excludeFilter && excludeFilter(e)) {
|
||||||
QString relativeFilePath = rootDirectory.relativeFilePath(e.absoluteFilePath());
|
QString relativeFilePath = rootDirectory.relativeFilePath(e.absoluteFilePath());
|
||||||
if (excludeFilter && excludeFilter(relativeFilePath)) {
|
|
||||||
qDebug() << "Skipping file " << relativeFilePath;
|
qDebug() << "Skipping file " << relativeFilePath;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,7 @@
|
|||||||
|
|
||||||
namespace MMCZip {
|
namespace MMCZip {
|
||||||
using FilterFunction = std::function<bool(const QString&)>;
|
using FilterFunction = std::function<bool(const QString&)>;
|
||||||
|
using FilterFileFunction = std::function<bool(const QFileInfo&)>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merge two zip files, using a filter function
|
* Merge two zip files, using a filter function
|
||||||
@ -149,7 +150,7 @@ bool extractFile(QString fileCompressed, QString file, QString dir);
|
|||||||
* \param excludeFilter function to excludeFilter which files shouldn't be included (returning true means to excude)
|
* \param excludeFilter function to excludeFilter which files shouldn't be included (returning true means to excude)
|
||||||
* \return true for success or false for failure
|
* \return true for success or false for failure
|
||||||
*/
|
*/
|
||||||
bool collectFileListRecursively(const QString& rootDir, const QString& subDir, QFileInfoList* files, FilterFunction excludeFilter);
|
bool collectFileListRecursively(const QString& rootDir, const QString& subDir, QFileInfoList* files, FilterFileFunction excludeFilter);
|
||||||
|
|
||||||
#if defined(LAUNCHER_APPLICATION)
|
#if defined(LAUNCHER_APPLICATION)
|
||||||
class ExportToZipTask : public Task {
|
class ExportToZipTask : public Task {
|
||||||
|
@ -47,7 +47,7 @@ FlamePackExportTask::FlamePackExportTask(const QString& name,
|
|||||||
bool optionalFiles,
|
bool optionalFiles,
|
||||||
InstancePtr instance,
|
InstancePtr instance,
|
||||||
const QString& output,
|
const QString& output,
|
||||||
MMCZip::FilterFunction filter)
|
MMCZip::FilterFileFunction filter)
|
||||||
: name(name)
|
: name(name)
|
||||||
, version(version)
|
, version(version)
|
||||||
, author(author)
|
, author(author)
|
||||||
|
@ -34,7 +34,7 @@ class FlamePackExportTask : public Task {
|
|||||||
bool optionalFiles,
|
bool optionalFiles,
|
||||||
InstancePtr instance,
|
InstancePtr instance,
|
||||||
const QString& output,
|
const QString& output,
|
||||||
MMCZip::FilterFunction filter);
|
MMCZip::FilterFileFunction filter);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void executeTask() override;
|
void executeTask() override;
|
||||||
@ -51,7 +51,7 @@ class FlamePackExportTask : public Task {
|
|||||||
MinecraftInstance* mcInstance;
|
MinecraftInstance* mcInstance;
|
||||||
const QDir gameRoot;
|
const QDir gameRoot;
|
||||||
const QString output;
|
const QString output;
|
||||||
const MMCZip::FilterFunction filter;
|
const MMCZip::FilterFileFunction filter;
|
||||||
|
|
||||||
struct ResolvedFile {
|
struct ResolvedFile {
|
||||||
int addonId;
|
int addonId;
|
||||||
|
@ -40,7 +40,7 @@ ModrinthPackExportTask::ModrinthPackExportTask(const QString& name,
|
|||||||
bool optionalFiles,
|
bool optionalFiles,
|
||||||
InstancePtr instance,
|
InstancePtr instance,
|
||||||
const QString& output,
|
const QString& output,
|
||||||
MMCZip::FilterFunction filter)
|
MMCZip::FilterFileFunction filter)
|
||||||
: name(name)
|
: name(name)
|
||||||
, version(version)
|
, version(version)
|
||||||
, summary(summary)
|
, summary(summary)
|
||||||
|
@ -35,7 +35,7 @@ class ModrinthPackExportTask : public Task {
|
|||||||
bool optionalFiles,
|
bool optionalFiles,
|
||||||
InstancePtr instance,
|
InstancePtr instance,
|
||||||
const QString& output,
|
const QString& output,
|
||||||
MMCZip::FilterFunction filter);
|
MMCZip::FilterFileFunction filter);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void executeTask() override;
|
void executeTask() override;
|
||||||
@ -58,7 +58,7 @@ class ModrinthPackExportTask : public Task {
|
|||||||
MinecraftInstance* mcInstance;
|
MinecraftInstance* mcInstance;
|
||||||
const QDir gameRoot;
|
const QDir gameRoot;
|
||||||
const QString output;
|
const QString output;
|
||||||
const MMCZip::FilterFunction filter;
|
const MMCZip::FilterFileFunction filter;
|
||||||
|
|
||||||
ModrinthAPI api;
|
ModrinthAPI api;
|
||||||
QFileInfoList files;
|
QFileInfoList files;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user