Factory Prest Assets

This commit is contained in:
Robin E.R. Davies
2026-05-31 02:46:12 -04:00
parent 68d195f9fb
commit 779f3c80ad
16 changed files with 60 additions and 45 deletions
+6
View File
@@ -317,6 +317,12 @@ namespace pipedal
bank.name(name);
bank.instanceId(++nextInstanceId_);
if (afterId == -2)
{
entries_.insert(entries_.begin(), bank);
return bank.instanceId();
}
for (size_t i = 0; i < this->entries_.size(); ++i)
{
if (entries_[i].instanceId() == afterId)
+33 -27
View File
@@ -179,38 +179,44 @@ static fs::path GetTone3000ThumbnailFile(const fs::path& thumbnailDirectory, con
return {};
}
int64_t ImportBankFile(PiPedalModel &model, const std::filesystem::path& filePath,uint64_t uploadAfter = -1)
{
BankFile bankFile;
namespace pipedal::implementation {
int64_t ImportBankFile(PiPedalModel &model, const std::filesystem::path& filePath,uint64_t uploadAfter = -1)
{
BankFile bankFile;
if (filePath.empty())
{
throw std::runtime_error("Unexpected.");
}
if (IsZipFile(filePath))
{
auto presetReader = PresetBundleReader::LoadPresetsFile(model, filePath);
presetReader->ExtractMediaFiles();
std::stringstream ss(presetReader->GetPresetJson());
json_reader reader(ss);
reader.read(&bankFile);
}
else
{
std::ifstream f {filePath};
if (!f.is_open()) {
throw std::runtime_error(SS("Unable to open file " << filePath));
if (filePath.empty())
{
throw std::runtime_error("Unexpected.");
}
// legacy json format, no zip, no media files.
json_reader reader(f);
reader.read(&bankFile);
}
uint64_t instanceId = model.UploadBank(bankFile, uploadAfter);
if (IsZipFile(filePath))
{
auto presetReader = PresetBundleReader::LoadPresetsFile(model, filePath);
presetReader->ExtractMediaFiles();
return instanceId;
std::stringstream ss(presetReader->GetPresetJson());
json_reader reader(ss);
reader.read(&bankFile);
}
else
{
std::ifstream f {filePath};
if (!f.is_open()) {
throw std::runtime_error(SS("Unable to open file " << filePath));
}
// legacy json format, no zip, no media files.
json_reader reader(f);
reader.read(&bankFile);
}
uint64_t instanceId = model.UploadBank(bankFile, uploadAfter);
return instanceId;
}
}
using namespace pipedal::implementation;
class DownloadIntercept : public RequestHandler
{
PiPedalModel* model;