fix(flame install): don't assume .zip is a resource pack. default to mod
let identifier move it if needed Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
parent
67d473aab7
commit
e704072892
@ -44,7 +44,11 @@ static const QMap<PackedResourceType, QString> s_packed_type_names = {
|
|||||||
namespace ResourceUtils {
|
namespace ResourceUtils {
|
||||||
PackedResourceType identify(QFileInfo file){
|
PackedResourceType identify(QFileInfo file){
|
||||||
if (file.exists() && file.isFile()) {
|
if (file.exists() && file.isFile()) {
|
||||||
if (ResourcePackUtils::validate(file)) {
|
if (ModUtils::validate(file)) {
|
||||||
|
// mods can contain resource and data packs so they much be tested first
|
||||||
|
qDebug() << file.fileName() << "is a mod";
|
||||||
|
return PackedResourceType::Mod;
|
||||||
|
} else if (ResourcePackUtils::validate(file)) {
|
||||||
qDebug() << file.fileName() << "is a resource pack";
|
qDebug() << file.fileName() << "is a resource pack";
|
||||||
return PackedResourceType::ResourcePack;
|
return PackedResourceType::ResourcePack;
|
||||||
} else if (TexturePackUtils::validate(file)) {
|
} else if (TexturePackUtils::validate(file)) {
|
||||||
@ -53,9 +57,6 @@ PackedResourceType identify(QFileInfo file){
|
|||||||
} else if (DataPackUtils::validate(file)) {
|
} else if (DataPackUtils::validate(file)) {
|
||||||
qDebug() << file.fileName() << "is a data pack";
|
qDebug() << file.fileName() << "is a data pack";
|
||||||
return PackedResourceType::DataPack;
|
return PackedResourceType::DataPack;
|
||||||
} else if (ModUtils::validate(file)) {
|
|
||||||
qDebug() << file.fileName() << "is a mod";
|
|
||||||
return PackedResourceType::Mod;
|
|
||||||
} else if (WorldSaveUtils::validate(file)) {
|
} else if (WorldSaveUtils::validate(file)) {
|
||||||
qDebug() << file.fileName() << "is a world save";
|
qDebug() << file.fileName() << "is a world save";
|
||||||
return PackedResourceType::WorldSave;
|
return PackedResourceType::WorldSave;
|
||||||
|
@ -563,6 +563,8 @@ void FlameCreationTask::validateZIPResouces()
|
|||||||
if (FS::move(localPath, destPath)) {
|
if (FS::move(localPath, destPath)) {
|
||||||
return destPath;
|
return destPath;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
qDebug() << "Target folder of" << fileName << "is correct at" << targetFolder;
|
||||||
}
|
}
|
||||||
return localPath;
|
return localPath;
|
||||||
};
|
};
|
||||||
@ -584,6 +586,9 @@ void FlameCreationTask::validateZIPResouces()
|
|||||||
QString worldPath;
|
QString worldPath;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
case PackedResourceType::Mod :
|
||||||
|
validatePath(fileName, targetFolder, "mods");
|
||||||
|
break;
|
||||||
case PackedResourceType::ResourcePack :
|
case PackedResourceType::ResourcePack :
|
||||||
validatePath(fileName, targetFolder, "resourcepacks");
|
validatePath(fileName, targetFolder, "resourcepacks");
|
||||||
break;
|
break;
|
||||||
@ -593,9 +598,6 @@ void FlameCreationTask::validateZIPResouces()
|
|||||||
case PackedResourceType::DataPack :
|
case PackedResourceType::DataPack :
|
||||||
validatePath(fileName, targetFolder, "datapacks");
|
validatePath(fileName, targetFolder, "datapacks");
|
||||||
break;
|
break;
|
||||||
case PackedResourceType::Mod :
|
|
||||||
validatePath(fileName, targetFolder, "mods");
|
|
||||||
break;
|
|
||||||
case PackedResourceType::ShaderPack :
|
case PackedResourceType::ShaderPack :
|
||||||
// in theroy flame API can't do this but who knows, that *may* change ?
|
// in theroy flame API can't do this but who knows, that *may* change ?
|
||||||
// better to handle it if it *does* occure in the future
|
// better to handle it if it *does* occure in the future
|
||||||
|
@ -76,13 +76,8 @@ bool Flame::File::parseFromObject(const QJsonObject& obj, bool throw_on_blocked
|
|||||||
// It is also optional
|
// It is also optional
|
||||||
type = File::Type::SingleFile;
|
type = File::Type::SingleFile;
|
||||||
|
|
||||||
if (fileName.endsWith(".zip")) {
|
|
||||||
// this is probably a resource pack
|
|
||||||
targetFolder = "resourcepacks";
|
|
||||||
} else {
|
|
||||||
// this is probably a mod, dunno what else could modpacks download
|
|
||||||
targetFolder = "mods";
|
targetFolder = "mods";
|
||||||
}
|
|
||||||
// get the hash
|
// get the hash
|
||||||
hash = QString();
|
hash = QString();
|
||||||
auto hashes = Json::ensureArray(obj, "hashes");
|
auto hashes = Json::ensureArray(obj, "hashes");
|
||||||
|
Loading…
Reference in New Issue
Block a user