From b821f748ac591258f015ecf3ba8011d5561c488d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 10 Mar 2011 21:56:15 +0000 Subject: For objects loaded from an IAR, make sure the CreatorID points towards the OSP resolved ID if newer CreationData is not present. This should resolve issues where the creator for rezzed objects was being shown as "Unknown user" where previous behaviour was to show the OSP resolved account. This is being done by parsing the serialized objects and updating the CreatorID if no CreationData exists. This operation might be expensive for sculpties where the sculpt texture is inlined with the object data. Will just have to see. This relies on the IAR streaming inventory data before asset data (as is currently the case). Will need to introduce more stringent checks for file order on loading (much like JAR zips must start with the manifest file). This is for IAR loading only. Tests updated to check this behaviour. --- .../Archiver/InventoryArchiveReadRequest.cs | 40 ++++++++++++++++++++-- .../Archiver/Tests/InventoryArchiverTests.cs | 10 +++--- 2 files changed, 42 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 7849d88..d0510d3 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs @@ -41,6 +41,7 @@ using OpenSim.Framework.Serialization; using OpenSim.Framework.Serialization.External; using OpenSim.Region.CoreModules.World.Archiver; using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Scenes.Serialization; using OpenSim.Region.Framework.Interfaces; using OpenSim.Services.Interfaces; @@ -75,6 +76,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// The stream from which the inventory archive will be loaded. /// private Stream m_loadStream; + + /// + /// Record the creator id that should be associated with an asset. This is used to adjust asset creator ids + /// after OSP resolution (since OSP creators are only stored in the item + /// + protected Dictionary m_creatorIdForAssetId = new Dictionary(); public InventoryArchiveReadRequest( Scene scene, UserAccount userInfo, string invPath, string loadPath, bool merge) @@ -420,6 +427,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver // Reset folder ID to the one in which we want to load it item.Folder = loadFolder.ID; + // Record the creator id for the item's asset so that we can use it later, if necessary, when the asset + // is loaded. + // FIXME: This relies on the items coming before the assets in the TAR file. Need to create stronger + // checks for this, and maybe even an external tool for creating OARs which enforces this, rather than + // relying on native tar tools. + m_creatorIdForAssetId[item.AssetID] = item.CreatorIdAsUuid; + m_scene.AddInventoryItem(item); return item; @@ -448,18 +462,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } string extension = filename.Substring(i); - string uuid = filename.Remove(filename.Length - extension.Length); + string rawUuid = filename.Remove(filename.Length - extension.Length); + UUID assetId = new UUID(rawUuid); if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension)) { sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; if (assetType == (sbyte)AssetType.Unknown) - m_log.WarnFormat("[INVENTORY ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, uuid); + { + m_log.WarnFormat("[INVENTORY ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, assetId); + } + else if (assetType == (sbyte)AssetType.Object) + { + if (m_creatorIdForAssetId.ContainsKey(assetId)) + { + string xmlData = Utils.BytesToString(data); + SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); + foreach (SceneObjectPart sop in sog.Parts) + { + if (sop.CreatorData == null || sop.CreatorData == "") + { + sop.CreatorID = m_creatorIdForAssetId[assetId]; + } + } + + data = Utils.StringToBytes(SceneObjectSerializer.ToOriginalXmlFormat(sog)); + } + } //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); - AssetBase asset = new AssetBase(new UUID(uuid), "RandomName", assetType, UUID.Zero.ToString()); + AssetBase asset = new AssetBase(assetId, "From IAR", assetType, UUID.Zero.ToString()); asset.Data = data; m_scene.AssetService.Store(asset); diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 3eb4104..5065227 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs @@ -207,11 +207,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests Assert.That(foundItem1.Owner, Is.EqualTo(m_ua1.PrincipalID), "Loaded item owner doesn't match inventory reciever"); -// AssetBase asset1 = scene.AssetService.Get(foundItem1.AssetID.ToString()); -// string xmlData = Utils.BytesToString(asset1.Data); -// SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); -// -// Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_ua3.PrincipalID.ToString())); + AssetBase asset1 = scene.AssetService.Get(foundItem1.AssetID.ToString()); + string xmlData = Utils.BytesToString(asset1.Data); + SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); + + Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_ua3.PrincipalID)); } /// -- cgit v1.1