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/ArchiveConstants.cs | 48 ++++++++++---------- .../Modules/World/Archiver/ArchiveReadRequest.cs | 51 +++++++++++++++++++--- .../Modules/World/Archiver/AssetsArchiver.cs | 2 +- 3 files changed, 69 insertions(+), 32 deletions(-) (limited to 'OpenSim/Region/Environment/Modules') diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs index 843dd0c..0766c95 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs @@ -59,50 +59,50 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver static ArchiveConstants() { ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Animation] = ".bvh"; - ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Bodypart] = ".bpt.txt"; - ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.CallingCard] = ".ccd.txt"; - ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Clothing] = ".clo.txt"; - ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Folder] = ".fld.txt"; // Not sure if we'll ever see this - ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Gesture] = ".gst.txt"; + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Bodypart] = ".bpt"; + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.CallingCard] = ".ccd"; + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Clothing] = ".clo"; + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Folder] = ".fld"; // Not sure if we'll ever see this + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Gesture] = ".gst"; ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.ImageJPEG] = ".jpg"; - ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.ImageTGA] = ".img.tga"; - ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.LostAndFoundFolder] = ".lff.txt"; // Not sure if we'll ever see this + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.ImageTGA] = ".imgtga"; + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.LostAndFoundFolder] = ".lfd"; // Not sure if we'll ever see this ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.LSLBytecode] = ".lso"; ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.LSLText] = ".lsl"; - ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Notecard] = ".ncd.txt"; - ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Object] = ".obj.xml"; - ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.RootFolder] = ".rof.txt"; // Not sure if we'll ever see this + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Notecard] = ".ncd"; + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Object] = ".oob"; + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.RootFolder] = ".rfd"; // Not sure if we'll ever see this ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Script] = ".spt"; // Not sure if we'll ever see this ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Simstate] = ".sst"; // Not sure if we'll ever see this - ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SnapshotFolder] = ".ssf.txt"; // Not sure if we'll ever see this + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SnapshotFolder] = ".sfd"; // Not sure if we'll ever see this ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Sound] = ".ogg"; ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SoundWAV] = ".wav"; ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Texture] = ".jp2"; ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TextureTGA] = ".tga"; - ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TrashFolder] = ".trf.txt"; // Not sure if we'll ever see this + ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TrashFolder] = ".tfd"; // Not sure if we'll ever see this EXTENSION_TO_ASSET_TYPE[".bvh"] = (sbyte)AssetType.Animation; - EXTENSION_TO_ASSET_TYPE[".bpt.txt"] = (sbyte)AssetType.Bodypart; - EXTENSION_TO_ASSET_TYPE[".ccd.txt"] = (sbyte)AssetType.CallingCard; - EXTENSION_TO_ASSET_TYPE[".clo.txt"] = (sbyte)AssetType.Clothing; - EXTENSION_TO_ASSET_TYPE[".fld.txt"] = (sbyte)AssetType.Folder; - EXTENSION_TO_ASSET_TYPE[".gst.txt"] = (sbyte)AssetType.Gesture; + EXTENSION_TO_ASSET_TYPE[".bpt"] = (sbyte)AssetType.Bodypart; + EXTENSION_TO_ASSET_TYPE[".ccd"] = (sbyte)AssetType.CallingCard; + EXTENSION_TO_ASSET_TYPE[".clo"] = (sbyte)AssetType.Clothing; + EXTENSION_TO_ASSET_TYPE[".fld"] = (sbyte)AssetType.Folder; + EXTENSION_TO_ASSET_TYPE[".gst"] = (sbyte)AssetType.Gesture; EXTENSION_TO_ASSET_TYPE[".jpg"] = (sbyte)AssetType.ImageJPEG; - EXTENSION_TO_ASSET_TYPE[".img.tga"] = (sbyte)AssetType.ImageTGA; - EXTENSION_TO_ASSET_TYPE[".lff.txt"] = (sbyte)AssetType.LostAndFoundFolder; + EXTENSION_TO_ASSET_TYPE[".imgtga"] = (sbyte)AssetType.ImageTGA; + EXTENSION_TO_ASSET_TYPE[".lfd"] = (sbyte)AssetType.LostAndFoundFolder; EXTENSION_TO_ASSET_TYPE[".lso"] = (sbyte)AssetType.LSLBytecode; EXTENSION_TO_ASSET_TYPE[".lsl"] = (sbyte)AssetType.LSLText; - EXTENSION_TO_ASSET_TYPE[".ncd.txt"] = (sbyte)AssetType.Notecard; - EXTENSION_TO_ASSET_TYPE[".obj.xml"] = (sbyte)AssetType.Object; - EXTENSION_TO_ASSET_TYPE[".rof.txt"] = (sbyte)AssetType.RootFolder; + EXTENSION_TO_ASSET_TYPE[".ncd"] = (sbyte)AssetType.Notecard; + EXTENSION_TO_ASSET_TYPE[".oob"] = (sbyte)AssetType.Object; + EXTENSION_TO_ASSET_TYPE[".rfd"] = (sbyte)AssetType.RootFolder; EXTENSION_TO_ASSET_TYPE[".spt"] = (sbyte)AssetType.Script; EXTENSION_TO_ASSET_TYPE[".sst"] = (sbyte)AssetType.Simstate; - EXTENSION_TO_ASSET_TYPE[".ssf.txt"] = (sbyte)AssetType.SnapshotFolder; + EXTENSION_TO_ASSET_TYPE[".sfd"] = (sbyte)AssetType.SnapshotFolder; EXTENSION_TO_ASSET_TYPE[".ogg"] = (sbyte)AssetType.Sound; EXTENSION_TO_ASSET_TYPE[".wav"] = (sbyte)AssetType.SoundWAV; EXTENSION_TO_ASSET_TYPE[".jp2"] = (sbyte)AssetType.Texture; EXTENSION_TO_ASSET_TYPE[".tga"] = (sbyte)AssetType.TextureTGA; - EXTENSION_TO_ASSET_TYPE[".trf.txt"] = (sbyte)AssetType.TrashFolder; + EXTENSION_TO_ASSET_TYPE[".tfd"] = (sbyte)AssetType.TrashFolder; } } } 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; + } + } } } diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs index 4922362..ed07c9f 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs @@ -58,7 +58,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver /// public void Archive(TarArchiveWriter archive) { - WriteMetadata(archive); + //WriteMetadata(archive); WriteData(archive); } -- cgit v1.1