From ca97dda60378fe250d5f410ee6f64e056af8ad3b Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Sun, 6 Jul 2008 16:19:04 +0000
Subject: * In archiver, scan scripts for embedded asset uuids and save these
out
---
.../Archiver/ArchiveWriteRequestPreparation.cs | 40 +++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs
index 11d0c65..04f64c3 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs
@@ -34,6 +34,7 @@ using OpenSim.Region.Environment.Scenes;
using System.Collections.Generic;
using System.Reflection;
//using System.Text;
+using System.Text.RegularExpressions;
using System.Threading;
using libsecondlife;
using log4net;
@@ -50,6 +51,14 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
protected Scene m_scene;
protected string m_savePath;
+
+ ///
+ /// Used for identifying uuids embedded in scripts
+ ///
+ protected static readonly Regex m_uuidRegex
+ = new Regex(
+ "[0-9a-eA-E]{8}-[0-9a-eA-E]{4}-[0-9a-eA-E]{4}-[0-9a-eA-E]{4}-[0-9a-eA-E]{12}",
+ RegexOptions.Compiled);
///
/// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate
@@ -114,6 +123,31 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
}
///
+ /// Record the asset uuids embedded within the given script.
+ ///
+ ///
+ /// Dictionary in which to record the references
+ protected void GetScriptAssetUuids(LLUUID scriptUuid, IDictionary assetUuids)
+ {
+ AssetBase scriptAsset = GetAsset(scriptUuid);
+
+ if (null != scriptAsset)
+ {
+ string script = Helpers.FieldToUTF8String(scriptAsset.Data);
+ m_log.DebugFormat("[ARCHIVER]: Script {0}", script);
+ MatchCollection uuidMatches = m_uuidRegex.Matches(script);
+ m_log.DebugFormat("[ARCHIVER]: Found {0} matches in script", uuidMatches.Count);
+
+ foreach (Match uuidMatch in uuidMatches)
+ {
+ LLUUID uuid = new LLUUID(uuidMatch.Value);
+ m_log.DebugFormat("[ARCHIVER]: Recording {0} in script", uuid);
+ assetUuids[uuid] = 1;
+ }
+ }
+ }
+
+ ///
/// Record the uuids referenced by the given wearable asset
///
///
@@ -200,7 +234,11 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
{
GetWearableAssetUuids(tii.AssetID, assetUuids);
}
- if ((int)AssetType.Object == tii.Type)
+ else if ((int)AssetType.LSLText == tii.Type)
+ {
+ GetScriptAssetUuids(tii.AssetID, assetUuids);
+ }
+ else if ((int)AssetType.Object == tii.Type)
{
GetSceneObjectAssetUuids(tii.AssetID, assetUuids);
}
--
cgit v1.1