mirror of
https://github.com/Misterblue/convoar.git
synced 2026-08-14 00:57:55 +00:00
When using long storage names, have images use their SHA256 value as filename.
This commit is contained in:
@@ -1424,7 +1424,8 @@ namespace org.herbal3d.cs.os.CommonEntities {
|
||||
}
|
||||
|
||||
public void WriteImage() {
|
||||
string imgFilename = this.GetFilename(underlyingUUID.ToString());
|
||||
// string imgFilename = this.GetFilename(underlyingUUID.ToString());
|
||||
string imgFilename = this.GetFilename(imageInfo.GetBHash().ToString());
|
||||
string imgDir = this.GetStorageDir(null, imgFilename);
|
||||
string absDir = PersistRules.CreateDirectory(imgDir, _params);
|
||||
var targetType = PersistRules.FigureOutTargetTypeFromAssetType(AssetType, _params);
|
||||
@@ -1433,7 +1434,8 @@ namespace org.herbal3d.cs.os.CommonEntities {
|
||||
}
|
||||
|
||||
public override Object AsJSON() {
|
||||
string imgFilename = this.GetFilename(underlyingUUID.ToString());
|
||||
// string imgFilename = this.GetFilename(underlyingUUID.ToString());
|
||||
string imgFilename = this.GetFilename(imageInfo.GetBHash().ToString());
|
||||
var ret = new Dictionary<string, Object> {
|
||||
{ "uri", PersistRules.ReferenceURL(_params.P<string>("URIBase"), imgFilename) }
|
||||
};
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.IO;
|
||||
|
||||
using OMV = OpenMetaverse;
|
||||
|
||||
@@ -33,6 +34,8 @@ namespace org.herbal3d.cs.os.CommonEntities {
|
||||
public int xSize = 0;
|
||||
public int ySize = 0;
|
||||
|
||||
private BHash _imageHash;
|
||||
|
||||
#pragma warning disable 414
|
||||
private readonly string _logHeader = "[ImageInfo]";
|
||||
#pragma warning restore 414
|
||||
@@ -65,13 +68,17 @@ namespace org.herbal3d.cs.os.CommonEntities {
|
||||
xSize = image.Width;
|
||||
ySize = image.Height;
|
||||
hasTransprency = CheckForTransparency();
|
||||
ComputeImageHash();
|
||||
// _log.DebugFormat("{0} SetImage. ID={1}, xSize={2}, ySize={3}, hasTrans={4}",
|
||||
// _logHeader, handle, xSize, ySize, hasTransprency);
|
||||
}
|
||||
|
||||
// The hash code for an image is just the hash of its UUID handle.
|
||||
public BHash GetBHash() {
|
||||
return handle.GetBHash();
|
||||
if (_imageHash == null) {
|
||||
return handle.GetBHash();
|
||||
}
|
||||
return _imageHash;
|
||||
}
|
||||
|
||||
// Check the image in this TextureInfo for transparency and set this.hasTransparency.
|
||||
@@ -125,11 +132,26 @@ namespace org.herbal3d.cs.os.CommonEntities {
|
||||
image = thumbNail;
|
||||
xSize = thumbNail.Width;
|
||||
ySize = thumbNail.Height;
|
||||
ComputeImageHash();
|
||||
ret = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Computes a SHA256 hash of the image
|
||||
public void ComputeImageHash() {
|
||||
BHasher hasher = new BHasherSHA256();
|
||||
if (image != null) {
|
||||
ImageConverter converter = new ImageConverter();
|
||||
byte[] data = (byte[])converter.ConvertTo(image, typeof(byte[]));
|
||||
_imageHash = hasher.Finish(data, 0, data.Length);
|
||||
}
|
||||
else {
|
||||
// If there isn't an image, use the UUID
|
||||
_imageHash = hasher.Finish(imageIdentifier.GetBytes(), 0, 16);
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("id={0},{1}x{2}{3}", handle.GetUUID(),
|
||||
|
||||
@@ -1 +1 @@
|
||||
Sat 02/16/2019 20:19:46.34
|
||||
Sat 02/16/2019 20:54:16.97
|
||||
|
||||
@@ -1 +1 @@
|
||||
3587d7ce6f067a16ff27c5d3b2133bb203eb41a6
|
||||
56280830e340a2686cbe958aa11c4182e8bc4da2
|
||||
|
||||
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Reference in New Issue
Block a user