FSAssets: truncate assets name and description to max size

0.9.1.0-post-fixes
UbitUmarov 2018-11-12 20:46:11 +00:00
parent c28738a17f
commit 7fcb3fdf11
1 changed files with 18 additions and 1 deletions

View File

@ -329,7 +329,6 @@ namespace OpenSim.Services.FSAssetService
using (GZipStream gz = new GZipStream(new FileStream(diskFile + ".gz", FileMode.Create), CompressionMode.Compress))
{
gz.Write(data, 0, data.Length);
gz.Close();
}
File.Delete(files[i]);
@ -620,6 +619,24 @@ namespace OpenSim.Services.FSAssetService
int tickCount = Environment.TickCount;
string hash = GetSHA256Hash(asset.Data);
if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
{
string assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
m_log.WarnFormat(
"[FSASSETS]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
asset.Name, asset.ID, asset.Name.Length, assetName.Length);
asset.Name = assetName;
}
if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
{
string assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
m_log.WarnFormat(
"[FSASSETS]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
asset.Description = assetDescription;
}
if (!AssetExists(hash))
{
string tempFile = Path.Combine(Path.Combine(m_SpoolDirectory, "spool"), hash + ".asset");