mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 12:57:59 +02:00
Add option to limit assets filesize in settings
This commit is contained in:
parent
cd2a742974
commit
19b00e1364
5 changed files with 30 additions and 7 deletions
|
@ -228,7 +228,8 @@ void updateConsumedCores() {
|
||||||
AssetServer::AssetServer(ReceivedMessage& message) :
|
AssetServer::AssetServer(ReceivedMessage& message) :
|
||||||
ThreadedAssignment(message),
|
ThreadedAssignment(message),
|
||||||
_transferTaskPool(this),
|
_transferTaskPool(this),
|
||||||
_bakingTaskPool(this)
|
_bakingTaskPool(this),
|
||||||
|
_filesizeLimit(MAX_UPLOAD_SIZE)
|
||||||
{
|
{
|
||||||
// store the current state of image compression so we can reset it when this assignment is complete
|
// store the current state of image compression so we can reset it when this assignment is complete
|
||||||
_wasColorTextureCompressionEnabled = image::isColorTexturesCompressionEnabled();
|
_wasColorTextureCompressionEnabled = image::isColorTexturesCompressionEnabled();
|
||||||
|
@ -336,8 +337,8 @@ void AssetServer::completeSetup() {
|
||||||
auto maxBandwidthValue = assetServerObject[MAX_BANDWIDTH_OPTION];
|
auto maxBandwidthValue = assetServerObject[MAX_BANDWIDTH_OPTION];
|
||||||
auto maxBandwidthFloat = maxBandwidthValue.toDouble(-1);
|
auto maxBandwidthFloat = maxBandwidthValue.toDouble(-1);
|
||||||
|
|
||||||
if (maxBandwidthFloat > 0.0) {
|
|
||||||
const int BITS_PER_MEGABITS = 1000 * 1000;
|
const int BITS_PER_MEGABITS = 1000 * 1000;
|
||||||
|
if (maxBandwidthFloat > 0.0) {
|
||||||
int maxBandwidth = maxBandwidthFloat * BITS_PER_MEGABITS;
|
int maxBandwidth = maxBandwidthFloat * BITS_PER_MEGABITS;
|
||||||
nodeList->setConnectionMaxBandwidth(maxBandwidth);
|
nodeList->setConnectionMaxBandwidth(maxBandwidth);
|
||||||
qCInfo(asset_server) << "Set maximum bandwith per connection to" << maxBandwidthFloat << "Mb/s."
|
qCInfo(asset_server) << "Set maximum bandwith per connection to" << maxBandwidthFloat << "Mb/s."
|
||||||
|
@ -399,6 +400,15 @@ void AssetServer::completeSetup() {
|
||||||
qCCritical(asset_server) << "Asset Server assignment will not continue because mapping file could not be loaded.";
|
qCCritical(asset_server) << "Asset Server assignment will not continue because mapping file could not be loaded.";
|
||||||
setFinished(true);
|
setFinished(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get file size limit for an asset
|
||||||
|
static const QString ASSETS_FILESIZE_LIMIT_OPTION = "assets_filesize_limit";
|
||||||
|
auto assetsFilesizeLimitJSONValue = assetServerObject[ASSETS_FILESIZE_LIMIT_OPTION];
|
||||||
|
auto assetsFilesizeLimit = assetsFilesizeLimitJSONValue.toInt(MAX_UPLOAD_SIZE);
|
||||||
|
|
||||||
|
if (assetsFilesizeLimit != 0 && assetsFilesizeLimit < MAX_UPLOAD_SIZE) {
|
||||||
|
_filesizeLimit = assetsFilesizeLimit * BITS_PER_MEGABITS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssetServer::cleanupUnmappedFiles() {
|
void AssetServer::cleanupUnmappedFiles() {
|
||||||
|
@ -721,7 +731,7 @@ void AssetServer::handleAssetUpload(QSharedPointer<ReceivedMessage> message, Sha
|
||||||
if (senderNode->getCanWriteToAssetServer()) {
|
if (senderNode->getCanWriteToAssetServer()) {
|
||||||
qCDebug(asset_server) << "Starting an UploadAssetTask for upload from" << uuidStringWithoutCurlyBraces(senderNode->getUUID());
|
qCDebug(asset_server) << "Starting an UploadAssetTask for upload from" << uuidStringWithoutCurlyBraces(senderNode->getUUID());
|
||||||
|
|
||||||
auto task = new UploadAssetTask(message, senderNode, _filesDirectory);
|
auto task = new UploadAssetTask(message, senderNode, _filesDirectory, _filesizeLimit);
|
||||||
_transferTaskPool.start(task);
|
_transferTaskPool.start(task);
|
||||||
} else {
|
} else {
|
||||||
// this is a node the domain told us is not allowed to rez entities
|
// this is a node the domain told us is not allowed to rez entities
|
||||||
|
|
|
@ -127,6 +127,8 @@ private:
|
||||||
bool _wasGrayscaleTextureCompressionEnabled { false };
|
bool _wasGrayscaleTextureCompressionEnabled { false };
|
||||||
bool _wasNormalTextureCompressionEnabled { false };
|
bool _wasNormalTextureCompressionEnabled { false };
|
||||||
bool _wasCubeTextureCompressionEnabled { false };
|
bool _wasCubeTextureCompressionEnabled { false };
|
||||||
|
|
||||||
|
uint64_t _filesizeLimit;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -22,10 +22,11 @@
|
||||||
|
|
||||||
|
|
||||||
UploadAssetTask::UploadAssetTask(QSharedPointer<ReceivedMessage> receivedMessage, SharedNodePointer senderNode,
|
UploadAssetTask::UploadAssetTask(QSharedPointer<ReceivedMessage> receivedMessage, SharedNodePointer senderNode,
|
||||||
const QDir& resourcesDir) :
|
const QDir& resourcesDir, uint64_t filesizeLimit) :
|
||||||
_receivedMessage(receivedMessage),
|
_receivedMessage(receivedMessage),
|
||||||
_senderNode(senderNode),
|
_senderNode(senderNode),
|
||||||
_resourcesDir(resourcesDir)
|
_resourcesDir(resourcesDir),
|
||||||
|
_filesizeLimit(filesizeLimit)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -48,7 +49,7 @@ void UploadAssetTask::run() {
|
||||||
auto replyPacket = NLPacket::create(PacketType::AssetUploadReply, -1, true);
|
auto replyPacket = NLPacket::create(PacketType::AssetUploadReply, -1, true);
|
||||||
replyPacket->writePrimitive(messageID);
|
replyPacket->writePrimitive(messageID);
|
||||||
|
|
||||||
if (fileSize > MAX_UPLOAD_SIZE) {
|
if (fileSize > _filesizeLimit) {
|
||||||
replyPacket->writePrimitive(AssetServerError::AssetTooLarge);
|
replyPacket->writePrimitive(AssetServerError::AssetTooLarge);
|
||||||
} else {
|
} else {
|
||||||
QByteArray fileData = buffer.read(fileSize);
|
QByteArray fileData = buffer.read(fileSize);
|
||||||
|
|
|
@ -26,7 +26,8 @@ class Node;
|
||||||
|
|
||||||
class UploadAssetTask : public QRunnable {
|
class UploadAssetTask : public QRunnable {
|
||||||
public:
|
public:
|
||||||
UploadAssetTask(QSharedPointer<ReceivedMessage> message, QSharedPointer<Node> senderNode, const QDir& resourcesDir);
|
UploadAssetTask(QSharedPointer<ReceivedMessage> message, QSharedPointer<Node> senderNode,
|
||||||
|
const QDir& resourcesDir, uint64_t filesizeLimit);
|
||||||
|
|
||||||
void run() override;
|
void run() override;
|
||||||
|
|
||||||
|
@ -34,6 +35,7 @@ private:
|
||||||
QSharedPointer<ReceivedMessage> _receivedMessage;
|
QSharedPointer<ReceivedMessage> _receivedMessage;
|
||||||
QSharedPointer<Node> _senderNode;
|
QSharedPointer<Node> _senderNode;
|
||||||
QDir _resourcesDir;
|
QDir _resourcesDir;
|
||||||
|
uint64_t _filesizeLimit;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_UploadAssetTask_h
|
#endif // hifi_UploadAssetTask_h
|
||||||
|
|
|
@ -858,6 +858,14 @@
|
||||||
"help": "The path to the directory assets are stored in.<br/>If this path is relative, it will be relative to the application data directory.<br/>If you change this path you will need to manually copy any existing assets from the previous directory.",
|
"help": "The path to the directory assets are stored in.<br/>If this path is relative, it will be relative to the application data directory.<br/>If you change this path you will need to manually copy any existing assets from the previous directory.",
|
||||||
"default": "",
|
"default": "",
|
||||||
"advanced": true
|
"advanced": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "assets_filesize_limit",
|
||||||
|
"type": "int",
|
||||||
|
"label": "File Size Limit",
|
||||||
|
"help": "The file size limit of an asset that can be imported into the asset server in MBytes. 0 (default) means no limit on file size.",
|
||||||
|
"default": 0,
|
||||||
|
"advanced": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue