diff options
author | Justin Clark-Casey (justincc) | 2011-03-10 21:56:15 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-03-10 21:56:15 +0000 |
commit | b821f748ac591258f015ecf3ba8011d5561c488d (patch) | |
tree | 8b5ca932c93911faea4fa8603a7452cd2de9f90f /OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |
parent | in AssetHelpers.CreateAsset(), create objects using the 'original' xml format... (diff) | |
download | opensim-SC_OLD-b821f748ac591258f015ecf3ba8011d5561c488d.zip opensim-SC_OLD-b821f748ac591258f015ecf3ba8011d5561c488d.tar.gz opensim-SC_OLD-b821f748ac591258f015ecf3ba8011d5561c488d.tar.bz2 opensim-SC_OLD-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 '')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | 40 |
1 files changed, 37 insertions, 3 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; | |||
41 | using OpenSim.Framework.Serialization.External; | 41 | using OpenSim.Framework.Serialization.External; |
42 | using OpenSim.Region.CoreModules.World.Archiver; | 42 | using OpenSim.Region.CoreModules.World.Archiver; |
43 | using OpenSim.Region.Framework.Scenes; | 43 | using OpenSim.Region.Framework.Scenes; |
44 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
44 | using OpenSim.Region.Framework.Interfaces; | 45 | using OpenSim.Region.Framework.Interfaces; |
45 | using OpenSim.Services.Interfaces; | 46 | using 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); |