From 73c115702777b62233737cf0de4e8ec4f3878f19 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 5 Jun 2008 00:29:02 +0000 Subject: * exprimental: Export and reimport all items within a prim except Objects * Not yet ready for public use --- .../Modules/World/Archiver/ArchiveConstants.cs | 2 +- .../Modules/World/Archiver/ArchiveWriteRequest.cs | 4 +-- .../Modules/World/Archiver/AssetsArchiver.cs | 29 +++++++++++++++++----- .../Modules/World/Archiver/AssetsDearchiver.cs | 12 ++++++--- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs index 872eb77..5bc1952 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs @@ -35,7 +35,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver /// /// Path for the assets held in an archive /// - public static readonly string ASSETS_PATH = "textures/"; + public static readonly string ASSETS_PATH = "assets/"; /// /// Extension used for texture assets in archive diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs index 41f230c..0a710b8 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs @@ -92,9 +92,9 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver foreach (TaskInventoryItem tit in part.TaskInventory.Values) { - if (tit.Type == (int)InventoryType.Texture) + if (tit.Type != (int)InventoryType.Object) { - m_log.DebugFormat("[ARCHIVER]: Recording texture {0} in object {1}", tit.AssetID, part.UUID); + m_log.DebugFormat("[ARCHIVER]: Recording asset {0} in object {1}", tit.AssetID, part.UUID); textureUuids[tit.AssetID] = 1; } } diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs index ed5f0e7..2a041dd 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs @@ -78,13 +78,21 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver foreach (LLUUID uuid in m_assets.Keys) { - if (m_assets[uuid] != null) + AssetBase asset = m_assets[uuid]; + + if (asset != null) { xtw.WriteStartElement("asset"); - AssetBase asset = m_assets[uuid]; + string extension = string.Empty; + + if ((sbyte)AssetType.Texture == asset.Type) + { + extension = ArchiveConstants.TEXTURE_EXTENSION; + } + + xtw.WriteElementString("filename", uuid.ToString() + extension); - xtw.WriteElementString("filename", uuid.ToString() + ArchiveConstants.TEXTURE_EXTENSION); xtw.WriteElementString("name", asset.Name); xtw.WriteElementString("description", asset.Description); xtw.WriteElementString("asset-type", asset.Type.ToString()); @@ -113,11 +121,20 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver foreach (LLUUID uuid in m_assets.Keys) { - if (m_assets[uuid] != null) + AssetBase asset = m_assets[uuid]; + + if (asset != null) { + string extension = string.Empty; + + if ((sbyte)AssetType.Texture == asset.Type) + { + extension = ArchiveConstants.TEXTURE_EXTENSION; + } + archive.AddFile( - ArchiveConstants.ASSETS_PATH + uuid.ToString() + ArchiveConstants.TEXTURE_EXTENSION, - m_assets[uuid].Data); + ArchiveConstants.ASSETS_PATH + uuid.ToString() + extension, + asset.Data); } else { diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsDearchiver.cs b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsDearchiver.cs index 9e63ccf..0c56ae3 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsDearchiver.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsDearchiver.cs @@ -97,7 +97,6 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver reader.ReadStartElement("assets"); reader.Read(); - m_log.DebugFormat("next node {0}", reader.Name); while (reader.Name.Equals("asset")) { reader.Read(); @@ -150,11 +149,16 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver { AssetMetadata metadata = m_metadata[filename]; - string rawId = filename.Remove(filename.Length - ArchiveConstants.TEXTURE_EXTENSION.Length); + string extension = String.Empty; + + if ((sbyte)AssetType.Texture == metadata.AssetType) + { + filename = filename.Remove(filename.Length - ArchiveConstants.TEXTURE_EXTENSION.Length); + } - m_log.DebugFormat("[ARCHIVER]: Importing asset {0}", rawId); + m_log.DebugFormat("[ARCHIVER]: Importing asset {0}", filename); - AssetBase asset = new AssetBase(new LLUUID(rawId), metadata.Name); + AssetBase asset = new AssetBase(new LLUUID(filename), metadata.Name); asset.Description = metadata.Description; asset.Type = metadata.AssetType; asset.InvType = metadata.InventoryType; -- cgit v1.1