Fix models and uploads for Mike's NAM
This commit is contained in:
+16
-9
@@ -681,19 +681,26 @@ Lv2PluginInfo::FindWritablePathProperties(PluginHost *lv2Host, const LilvPlugin
|
|||||||
std::filesystem::path bundleDirectoryName = std::filesystem::path(bundle_path()).parent_path().filename();
|
std::filesystem::path bundleDirectoryName = std::filesystem::path(bundle_path()).parent_path().filename();
|
||||||
std::filesystem::path legacyUploadPath = lv2Host->MapPath(bundleDirectoryName.string());
|
std::filesystem::path legacyUploadPath = lv2Host->MapPath(bundleDirectoryName.string());
|
||||||
|
|
||||||
if (std::filesystem::exists(legacyUploadPath))
|
|
||||||
{
|
|
||||||
if (!std::filesystem::exists(legacyUploadPath / ".migrated"))
|
|
||||||
{
|
|
||||||
fileProperty->useLegacyModDirectory(true);
|
|
||||||
fileProperty->directory(bundleDirectoryName);
|
|
||||||
}
|
|
||||||
modFileTypes.rootDirectories().push_back(bundleDirectoryName.filename()); // push the private directory!
|
|
||||||
}
|
|
||||||
fileProperty->setModFileTypes(modFileTypes);
|
fileProperty->setModFileTypes(modFileTypes);
|
||||||
|
|
||||||
fileProperty->directory(bundleDirectoryName);
|
fileProperty->directory(bundleDirectoryName);
|
||||||
|
|
||||||
|
if (std::filesystem::exists(legacyUploadPath)
|
||||||
|
&& !std::filesystem::exists(legacyUploadPath / ".migrated"))
|
||||||
|
{
|
||||||
|
fileProperty->useLegacyModDirectory(true);
|
||||||
|
fileProperty->directory(bundleDirectoryName);
|
||||||
|
modFileTypes.rootDirectories().push_back(bundleDirectoryName.filename()); // push the private directory!
|
||||||
|
} else {
|
||||||
|
if (modFileTypes.rootDirectories().size() == 1)
|
||||||
|
{
|
||||||
|
std::string modName = modFileTypes.rootDirectories()[0];
|
||||||
|
auto modDirectory = modFileTypes.GetModDirectory(modName);
|
||||||
|
fileProperty->directory(modDirectory->pipedalPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fileProperties.push_back(fileProperty);
|
fileProperties.push_back(fileProperty);
|
||||||
} else {
|
} else {
|
||||||
unsupportedPatchProperty = true;
|
unsupportedPatchProperty = true;
|
||||||
|
|||||||
+45
-1
@@ -636,6 +636,40 @@ std::string GetFromAddress(const tcp::socket &socket)
|
|||||||
s << socket.remote_endpoint().address().to_string() << ':' << socket.remote_endpoint().port();
|
s << socket.remote_endpoint().address().to_string() << ':' << socket.remote_endpoint().port();
|
||||||
return s.str();
|
return s.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool encoding_allowed(const std::string&acceptEncodingHeader,const std::string&encoding)
|
||||||
|
{
|
||||||
|
auto npos = acceptEncodingHeader.find(encoding);
|
||||||
|
if (npos == std::string::npos)
|
||||||
|
return false;
|
||||||
|
std::vector<std::string> encodings = split(acceptEncodingHeader, ',');
|
||||||
|
for (auto &e : encodings)
|
||||||
|
{
|
||||||
|
if (e.starts_with(encoding)) {
|
||||||
|
if (e.length() == encoding.length())
|
||||||
|
return true;
|
||||||
|
if (e[encoding.length()] == ';')
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool can_use_gzip_encoding(
|
||||||
|
const std::string &acceptEncodingHeader,
|
||||||
|
const std::filesystem::path &filename,
|
||||||
|
std::filesystem::path *gzName)
|
||||||
|
{
|
||||||
|
if (!encoding_allowed(acceptEncodingHeader, "gzip"))
|
||||||
|
return false;
|
||||||
|
*gzName = filename.string() + ".gz";
|
||||||
|
if (std::filesystem::exists(*gzName)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace pipedal
|
namespace pipedal
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -1125,12 +1159,22 @@ namespace pipedal
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string mimeType = mime_type(filename);
|
||||||
|
|
||||||
|
std::filesystem::path gzName;
|
||||||
|
|
||||||
|
if (can_use_gzip_encoding(req.get(HttpField::accept_encoding) ,filename,&gzName) )
|
||||||
|
{
|
||||||
|
filename = gzName;
|
||||||
|
res.set(HttpField::content_encoding,"gzip");
|
||||||
|
}
|
||||||
|
|
||||||
if (req.method() != HttpVerb::get)
|
if (req.method() != HttpVerb::get)
|
||||||
{
|
{
|
||||||
ServerError(*con, "Unknown HTTP-Method");
|
ServerError(*con, "Unknown HTTP-Method");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::string mimeType = mime_type(filename);
|
|
||||||
|
|
||||||
file.open(filename.c_str(), std::ios::in);
|
file.open(filename.c_str(), std::ios::in);
|
||||||
if (!file)
|
if (!file)
|
||||||
|
|||||||
@@ -71,6 +71,8 @@ public:
|
|||||||
constexpr static const char* date = "Date";
|
constexpr static const char* date = "Date";
|
||||||
constexpr static const char* referer = "Referer";
|
constexpr static const char* referer = "Referer";
|
||||||
constexpr static const char * location = "Location";
|
constexpr static const char * location = "Location";
|
||||||
|
constexpr static const char* accept_encoding = "Accept-Encoding";
|
||||||
|
constexpr static const char* content_encoding = "Content-Encoding";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Executable
+14
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
npm run build && \
|
||||||
|
#remove any existing .gz files.
|
||||||
|
if ls dist/assets/index*.js.gz 1> /dev/null 2>&1; then
|
||||||
|
rm dist/assets/index*.js.gz
|
||||||
|
fi
|
||||||
|
# generate a .gz file for each index*.js file
|
||||||
|
|
||||||
|
if ls dist/assets/index*.js 1> /dev/null 2>&1; then
|
||||||
|
for file in dist/assets/index*.js; do
|
||||||
|
# generate a .gz file
|
||||||
|
gzip -c $file > $file.gz
|
||||||
|
done
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user