aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-07-08 22:53:19 +0100
committerJustin Clark-Casey (justincc)2011-07-08 22:53:19 +0100
commitc3d82bdcb1ac2ee0e0bdad75fbf8779252ef31c4 (patch)
tree0e7050a1e23cb9f1bf3ffd23408fcea847ef91ee /OpenSim
parentstop the local inventory services connector from logging an error when an ite... (diff)
downloadopensim-SC_OLD-c3d82bdcb1ac2ee0e0bdad75fbf8779252ef31c4.zip
opensim-SC_OLD-c3d82bdcb1ac2ee0e0bdad75fbf8779252ef31c4.tar.gz
opensim-SC_OLD-c3d82bdcb1ac2ee0e0bdad75fbf8779252ef31c4.tar.bz2
opensim-SC_OLD-c3d82bdcb1ac2ee0e0bdad75fbf8779252ef31c4.tar.xz
When loading library asset set, only store an asset if it's different from an existing one with the same id.
We compare existing and loaded asset by doing an SHA1 on both, so that a changed library asset will still update the store. This cuts asset library load time from 10 seconds to <1 sec. Note, a fix on the previous commit revealed a bug where a library script cannot be copied except on the first login after a cache clear. This is unrelated to this commit and needs to be fixed at some subsequent time.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Util.cs16
-rw-r--r--OpenSim/Services/AssetService/AssetService.cs15
2 files changed, 25 insertions, 6 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 039b926..fce8999 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -440,20 +440,30 @@ namespace OpenSim.Framework
440 } 440 }
441 441
442 /// <summary> 442 /// <summary>
443 /// Return an SHA1 hash of the given string 443 /// Return an SHA1 hash
444 /// </summary> 444 /// </summary>
445 /// <param name="data"></param> 445 /// <param name="data"></param>
446 /// <returns></returns> 446 /// <returns></returns>
447 public static string SHA1Hash(string data) 447 public static string SHA1Hash(string data)
448 { 448 {
449 return SHA1Hash(Encoding.Default.GetBytes(data));
450 }
451
452 /// <summary>
453 /// Return an SHA1 hash
454 /// </summary>
455 /// <param name="data"></param>
456 /// <returns></returns>
457 public static string SHA1Hash(byte[] data)
458 {
449 byte[] hash = ComputeSHA1Hash(data); 459 byte[] hash = ComputeSHA1Hash(data);
450 return BitConverter.ToString(hash).Replace("-", String.Empty); 460 return BitConverter.ToString(hash).Replace("-", String.Empty);
451 } 461 }
452 462
453 private static byte[] ComputeSHA1Hash(string src) 463 private static byte[] ComputeSHA1Hash(byte[] src)
454 { 464 {
455 SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider(); 465 SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider();
456 return SHA1.ComputeHash(Encoding.Default.GetBytes(src)); 466 return SHA1.ComputeHash(src);
457 } 467 }
458 468
459 public static int fast_distance2d(int x, int y) 469 public static int fast_distance2d(int x, int y)
diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs
index 851b7b4..c7a259d 100644
--- a/OpenSim/Services/AssetService/AssetService.cs
+++ b/OpenSim/Services/AssetService/AssetService.cs
@@ -84,11 +84,20 @@ namespace OpenSim.Services.AssetService
84 if (assetLoaderEnabled) 84 if (assetLoaderEnabled)
85 { 85 {
86 m_log.InfoFormat("[ASSET]: Loading default asset set from {0}", loaderArgs); 86 m_log.InfoFormat("[ASSET]: Loading default asset set from {0}", loaderArgs);
87 m_AssetLoader.ForEachDefaultXmlAsset(loaderArgs, 87
88 delegate(AssetBase a) 88 m_AssetLoader.ForEachDefaultXmlAsset(
89 loaderArgs,
90 delegate(AssetBase a)
91 {
92 AssetBase existingAsset = Get(a.ID);
93// AssetMetadata existingMetadata = GetMetadata(a.ID);
94
95 if (existingAsset == null || Util.SHA1Hash(existingAsset.Data) != Util.SHA1Hash(a.Data))
89 { 96 {
97// m_log.DebugFormat("[ASSET]: Storing {0} {1}", a.Name, a.ID);
90 Store(a); 98 Store(a);
91 }); 99 }
100 });
92 } 101 }
93 102
94 m_log.Info("[ASSET SERVICE]: Local asset service enabled"); 103 m_log.Info("[ASSET SERVICE]: Local asset service enabled");