From 33f5d0d1e90c3e63e06a200043a01c32768335c1 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 15 Mar 2010 14:17:17 -0700 Subject: * UuidGatherer now tracks asset types for assets it discovers. The asset types are inferred from context * OAR saving will attempt to correct unknown asset types before writing broken assets to the OAR file --- .../Region/CoreModules/Asset/FlotsamAssetCache.cs | 2 +- .../Archiver/InventoryArchiveWriteRequest.cs | 4 ++-- .../Framework/InventoryAccess/HGAssetMapper.cs | 4 ++-- .../Archiver/ArchiveWriteRequestPreparation.cs | 14 ++++++------- .../CoreModules/World/Archiver/AssetsRequest.cs | 23 +++++++++++++++++----- 5 files changed, 30 insertions(+), 17 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 967c0a1..37cdaae 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -642,7 +642,7 @@ namespace Flotsam.RegionModules.AssetCache { UuidGatherer gatherer = new UuidGatherer(m_AssetService); - Dictionary assets = new Dictionary(); + Dictionary assets = new Dictionary(); foreach (Scene s in m_Scenes) { StampRegionStatusFile(s.RegionInfo.RegionID); diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index ef10104..cfe3caa 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -73,7 +73,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// /// Used to collect the uuids of the assets that we need to save into the archive /// - protected Dictionary m_assetUuids = new Dictionary(); + protected Dictionary m_assetUuids = new Dictionary(); /// /// Used to collect the uuids of the users that we need to save into the archive @@ -305,7 +305,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver } new AssetsRequest( - new AssetsArchiver(m_archiveWriter), m_assetUuids.Keys, + new AssetsArchiver(m_archiveWriter), m_assetUuids, m_scene.AssetService, ReceivedAllAssets).Execute(); } diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs index 664f38d..58ce550 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs @@ -150,7 +150,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess if (asset != null) { // OK, now fetch the inside. - Dictionary ids = new Dictionary(); + Dictionary ids = new Dictionary(); HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL); uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids); foreach (UUID uuid in ids.Keys) @@ -173,7 +173,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); if (asset != null) { - Dictionary ids = new Dictionary(); + Dictionary ids = new Dictionary(); HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty); uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids); foreach (UUID uuid in ids.Keys) diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs index b61b341..b25636f 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs @@ -100,7 +100,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// if there was an io problem with creating the file public void ArchiveRegion() { - Dictionary assetUuids = new Dictionary(); + Dictionary assetUuids = new Dictionary(); List entities = m_scene.GetEntities(); List sceneObjects = new List(); @@ -142,18 +142,18 @@ namespace OpenSim.Region.CoreModules.World.Archiver // Make sure that we also request terrain texture assets RegionSettings regionSettings = m_scene.RegionInfo.RegionSettings; - + if (regionSettings.TerrainTexture1 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_1) - assetUuids[regionSettings.TerrainTexture1] = 1; + assetUuids[regionSettings.TerrainTexture1] = AssetType.Texture; if (regionSettings.TerrainTexture2 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_2) - assetUuids[regionSettings.TerrainTexture2] = 1; + assetUuids[regionSettings.TerrainTexture2] = AssetType.Texture; if (regionSettings.TerrainTexture3 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_3) - assetUuids[regionSettings.TerrainTexture3] = 1; + assetUuids[regionSettings.TerrainTexture3] = AssetType.Texture; if (regionSettings.TerrainTexture4 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_4) - assetUuids[regionSettings.TerrainTexture4] = 1; + assetUuids[regionSettings.TerrainTexture4] = AssetType.Texture; TarArchiveWriter archiveWriter = new TarArchiveWriter(m_saveStream); @@ -168,7 +168,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver m_requestId); new AssetsRequest( - new AssetsArchiver(archiveWriter), assetUuids.Keys, + new AssetsArchiver(archiveWriter), assetUuids, m_scene.AssetService, awre.ReceivedAllAssets).Execute(); } } diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs index c9fce91..4215f97 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs @@ -74,7 +74,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver /// /// uuids to request /// - protected ICollection m_uuids; + protected IDictionary m_uuids; /// /// Callback used when all the assets requested have been received. @@ -104,7 +104,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver protected AssetsArchiver m_assetsArchiver; protected internal AssetsRequest( - AssetsArchiver assetsArchiver, ICollection uuids, + AssetsArchiver assetsArchiver, IDictionary uuids, IAssetService assetService, AssetsRequestCallback assetsRequestCallback) { m_assetsArchiver = assetsArchiver; @@ -132,9 +132,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver return; } - foreach (UUID uuid in m_uuids) + foreach (KeyValuePair kvp in m_uuids) { - m_assetService.Get(uuid.ToString(), this, AssetRequestCallback); + m_assetService.Get(kvp.Key.ToString(), kvp.Value, PreAssetRequestCallback); } m_requestCallbackTimer.Enabled = true; @@ -157,7 +157,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver // Calculate which uuids were not found. This is an expensive way of doing it, but this is a failure // case anyway. List uuids = new List(); - foreach (UUID uuid in m_uuids) + foreach (UUID uuid in m_uuids.Keys) { uuids.Add(uuid); } @@ -200,6 +200,19 @@ namespace OpenSim.Region.CoreModules.World.Archiver } } + protected void PreAssetRequestCallback(string fetchedAssetID, object assetType, AssetBase fetchedAsset) + { + // Check for broken asset types and fix them with the AssetType gleaned by UuidGatherer + if (fetchedAsset != null && fetchedAsset.Type == (sbyte)AssetType.Unknown) + { + AssetType type = (AssetType)assetType; + m_log.InfoFormat("[ARCHIVER]: Rewriting broken asset type for {0} to {1}", fetchedAsset.ID, type); + fetchedAsset.Type = (sbyte)type; + } + + AssetRequestCallback(fetchedAssetID, this, fetchedAsset); + } + /// /// Called back by the asset cache when it has the asset /// -- cgit v1.1