diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 039b926720..fce8999912 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -440,20 +440,30 @@ namespace OpenSim.Framework } /// - /// Return an SHA1 hash of the given string + /// Return an SHA1 hash /// /// /// public static string SHA1Hash(string data) + { + return SHA1Hash(Encoding.Default.GetBytes(data)); + } + + /// + /// Return an SHA1 hash + /// + /// + /// + public static string SHA1Hash(byte[] data) { byte[] hash = ComputeSHA1Hash(data); return BitConverter.ToString(hash).Replace("-", String.Empty); } - private static byte[] ComputeSHA1Hash(string src) + private static byte[] ComputeSHA1Hash(byte[] src) { SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider(); - return SHA1.ComputeHash(Encoding.Default.GetBytes(src)); + return SHA1.ComputeHash(src); } public static int fast_distance2d(int x, int y) diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs index 851b7b4693..c7a259d2ca 100644 --- a/OpenSim/Services/AssetService/AssetService.cs +++ b/OpenSim/Services/AssetService/AssetService.cs @@ -84,11 +84,20 @@ namespace OpenSim.Services.AssetService if (assetLoaderEnabled) { m_log.InfoFormat("[ASSET]: Loading default asset set from {0}", loaderArgs); - m_AssetLoader.ForEachDefaultXmlAsset(loaderArgs, - delegate(AssetBase a) + + m_AssetLoader.ForEachDefaultXmlAsset( + loaderArgs, + delegate(AssetBase a) + { + AssetBase existingAsset = Get(a.ID); +// AssetMetadata existingMetadata = GetMetadata(a.ID); + + if (existingAsset == null || Util.SHA1Hash(existingAsset.Data) != Util.SHA1Hash(a.Data)) { +// m_log.DebugFormat("[ASSET]: Storing {0} {1}", a.Name, a.ID); Store(a); - }); + } + }); } m_log.Info("[ASSET SERVICE]: Local asset service enabled");