diff options
3 files changed, 48 insertions, 10 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); |
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> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 67e59c6..fa404c0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -1089,9 +1089,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1089 | 1089 | ||
1090 | public Dictionary<UUID, string> GetScriptStates() | 1090 | public Dictionary<UUID, string> GetScriptStates() |
1091 | { | 1091 | { |
1092 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); | ||
1093 | |||
1094 | if (m_part.ParentGroup.Scene == null) // Group not in a scene | ||
1095 | return ret; | ||
1096 | |||
1092 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | 1097 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); |
1093 | 1098 | ||
1094 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); | ||
1095 | if (engines == null) // No engine at all | 1099 | if (engines == null) // No engine at all |
1096 | return ret; | 1100 | return ret; |
1097 | 1101 | ||