From 810d3da2b9e90ca52bfaf9b03233fcda6181ec8e Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 27 Jun 2008 20:08:29 +0000 Subject: * Experiment with not bothering with a seperate assets metadata file - extract necessary minimum metadata from asset filenames * Make all file extensions single - double extensions look ugly and probably aren't good for Windows --- .../Modules/World/Archiver/ArchiveReadRequest.cs | 51 +++++++++++++++++++--- 1 file changed, 44 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs') diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs index 8d882ea..8f73c2c 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs @@ -61,7 +61,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver protected void DearchiveRegion() { TarArchiveReader archive = new TarArchiveReader(m_loadPath); - AssetsDearchiver dearchiver = new AssetsDearchiver(m_scene.AssetCache); + //AssetsDearchiver dearchiver = new AssetsDearchiver(m_scene.AssetCache); List serialisedSceneObjects = new List(); string filePath = "ERROR"; @@ -76,14 +76,14 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver { serialisedSceneObjects.Add(m_asciiEncoding.GetString(data)); } - else if (filePath.Equals(ArchiveConstants.ASSETS_METADATA_PATH)) - { - string xml = m_asciiEncoding.GetString(data); - dearchiver.AddAssetMetadata(xml); - } +// else if (filePath.Equals(ArchiveConstants.ASSETS_METADATA_PATH)) +// { +// string xml = m_asciiEncoding.GetString(data); +// dearchiver.AddAssetMetadata(xml); +// } else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) { - dearchiver.AddAssetData(filePath, data); + ResolveAssetData(filePath, data); } } @@ -103,5 +103,42 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver m_log.InfoFormat("[ARCHIVER]: Successfully loaded archive"); } + + /// + /// Resolve a new piece of asset data against stored metadata + /// + /// + /// + /// true if asset was successfully loaded, false otherwise + protected bool ResolveAssetData(string assetPath, byte[] data) + { + // Right now we're nastily obtaining the lluuid from the filename + string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length); + string extension = filename.Substring(filename.LastIndexOf(".")); + string uuid = filename.Remove(filename.Length - extension.Length); + + if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension)) + { + sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; + + m_log.DebugFormat("[ARCHIVER]: Importing asset {0}", filename); + + AssetBase asset = new AssetBase(new LLUUID(uuid), String.Empty); + asset.Type = assetType; + asset.Data = data; + + m_scene.AssetCache.AddAsset(asset); + + return true; + } + else + { + m_log.ErrorFormat( + "[DEARCHIVER]: Tried to dearchive data with path {0} with an unknown type extension {1}", + assetPath, extension); + + return false; + } + } } } -- cgit v1.1