mirror of
https://github.com/opensim/opensim.git
synced 2026-08-12 04:05:42 +08:00
* 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
This commit is contained in:
@@ -100,7 +100,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
/// <exception cref="System.IO.IOException">if there was an io problem with creating the file</exception>
|
||||
public void ArchiveRegion()
|
||||
{
|
||||
Dictionary<UUID, int> assetUuids = new Dictionary<UUID, int>();
|
||||
Dictionary<UUID, AssetType> assetUuids = new Dictionary<UUID, AssetType>();
|
||||
|
||||
List<EntityBase> entities = m_scene.GetEntities();
|
||||
List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
/// <value>
|
||||
/// uuids to request
|
||||
/// </value>
|
||||
protected ICollection<UUID> m_uuids;
|
||||
protected IDictionary<UUID, AssetType> m_uuids;
|
||||
|
||||
/// <value>
|
||||
/// 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<UUID> uuids,
|
||||
AssetsArchiver assetsArchiver, IDictionary<UUID, AssetType> 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<UUID, AssetType> 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<UUID> uuids = new List<UUID>();
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called back by the asset cache when it has the asset
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user