aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-03-10 21:56:15 +0000
committerJustin Clark-Casey (justincc)2011-03-10 21:56:15 +0000
commitb821f748ac591258f015ecf3ba8011d5561c488d (patch)
tree8b5ca932c93911faea4fa8603a7452cd2de9f90f /OpenSim/Region/CoreModules
parentin AssetHelpers.CreateAsset(), create objects using the 'original' xml format... (diff)
downloadopensim-SC-b821f748ac591258f015ecf3ba8011d5561c488d.zip
opensim-SC-b821f748ac591258f015ecf3ba8011d5561c488d.tar.gz
opensim-SC-b821f748ac591258f015ecf3ba8011d5561c488d.tar.bz2
opensim-SC-b821f748ac591258f015ecf3ba8011d5561c488d.tar.xz
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.
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs40
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs10
2 files changed, 42 insertions, 8 deletions
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;
41using OpenSim.Framework.Serialization.External; 41using OpenSim.Framework.Serialization.External;
42using OpenSim.Region.CoreModules.World.Archiver; 42using OpenSim.Region.CoreModules.World.Archiver;
43using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
44using OpenSim.Region.Framework.Scenes.Serialization;
44using OpenSim.Region.Framework.Interfaces; 45using OpenSim.Region.Framework.Interfaces;
45using OpenSim.Services.Interfaces; 46using OpenSim.Services.Interfaces;
46 47
@@ -75,6 +76,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
75 /// The stream from which the inventory archive will be loaded. 76 /// The stream from which the inventory archive will be loaded.
76 /// </value> 77 /// </value>
77 private Stream m_loadStream; 78 private Stream m_loadStream;
79
80 /// <summary>
81 /// Record the creator id that should be associated with an asset. This is used to adjust asset creator ids
82 /// after OSP resolution (since OSP creators are only stored in the item
83 /// </summary>
84 protected Dictionary<UUID, UUID> m_creatorIdForAssetId = new Dictionary<UUID, UUID>();
78 85
79 public InventoryArchiveReadRequest( 86 public InventoryArchiveReadRequest(
80 Scene scene, UserAccount userInfo, string invPath, string loadPath, bool merge) 87 Scene scene, UserAccount userInfo, string invPath, string loadPath, bool merge)
@@ -420,6 +427,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
420 // Reset folder ID to the one in which we want to load it 427 // Reset folder ID to the one in which we want to load it
421 item.Folder = loadFolder.ID; 428 item.Folder = loadFolder.ID;
422 429
430 // Record the creator id for the item's asset so that we can use it later, if necessary, when the asset
431 // is loaded.
432 // FIXME: This relies on the items coming before the assets in the TAR file. Need to create stronger
433 // checks for this, and maybe even an external tool for creating OARs which enforces this, rather than
434 // relying on native tar tools.
435 m_creatorIdForAssetId[item.AssetID] = item.CreatorIdAsUuid;
436
423 m_scene.AddInventoryItem(item); 437 m_scene.AddInventoryItem(item);
424 438
425 return item; 439 return item;
@@ -448,18 +462,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
448 } 462 }
449 463
450 string extension = filename.Substring(i); 464 string extension = filename.Substring(i);
451 string uuid = filename.Remove(filename.Length - extension.Length); 465 string rawUuid = filename.Remove(filename.Length - extension.Length);
466 UUID assetId = new UUID(rawUuid);
452 467
453 if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension)) 468 if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension))
454 { 469 {
455 sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; 470 sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];
456 471
457 if (assetType == (sbyte)AssetType.Unknown) 472 if (assetType == (sbyte)AssetType.Unknown)
458 m_log.WarnFormat("[INVENTORY ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, uuid); 473 {
474 m_log.WarnFormat("[INVENTORY ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, assetId);
475 }
476 else if (assetType == (sbyte)AssetType.Object)
477 {
478 if (m_creatorIdForAssetId.ContainsKey(assetId))
479 {
480 string xmlData = Utils.BytesToString(data);
481 SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
482 foreach (SceneObjectPart sop in sog.Parts)
483 {
484 if (sop.CreatorData == null || sop.CreatorData == "")
485 {
486 sop.CreatorID = m_creatorIdForAssetId[assetId];
487 }
488 }
489
490 data = Utils.StringToBytes(SceneObjectSerializer.ToOriginalXmlFormat(sog));
491 }
492 }
459 493
460 //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); 494 //m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType);
461 495
462 AssetBase asset = new AssetBase(new UUID(uuid), "RandomName", assetType, UUID.Zero.ToString()); 496 AssetBase asset = new AssetBase(assetId, "From IAR", assetType, UUID.Zero.ToString());
463 asset.Data = data; 497 asset.Data = data;
464 498
465 m_scene.AssetService.Store(asset); 499 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
207 Assert.That(foundItem1.Owner, Is.EqualTo(m_ua1.PrincipalID), 207 Assert.That(foundItem1.Owner, Is.EqualTo(m_ua1.PrincipalID),
208 "Loaded item owner doesn't match inventory reciever"); 208 "Loaded item owner doesn't match inventory reciever");
209 209
210// AssetBase asset1 = scene.AssetService.Get(foundItem1.AssetID.ToString()); 210 AssetBase asset1 = scene.AssetService.Get(foundItem1.AssetID.ToString());
211// string xmlData = Utils.BytesToString(asset1.Data); 211 string xmlData = Utils.BytesToString(asset1.Data);
212// SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); 212 SceneObjectGroup sog1 = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
213// 213
214// Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_ua3.PrincipalID.ToString())); 214 Assert.That(sog1.RootPart.CreatorID, Is.EqualTo(m_ua3.PrincipalID));
215 } 215 }
216 216
217 /// <summary> 217 /// <summary>