From 9b22393cf308507dc751704c8b0d3e65ac1d4323 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 9 May 2010 17:02:22 +0100 Subject: [PATCH] Add a field asset_flags and a corresponding enum to the asset database. This CHANGES THE ASSET SERVER PROTOCOL and means you CAN NOT MIX PRIOR VERSIONS WITH LATER ONES. It may also eat your babies, yada, yada, yada. The usual cautions for migrations to the assets table apply. Coding: Can not guarantee nut free. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 8 ++++--- .../Data/MySQL/Resources/007_AssetStore.sql | 5 +++++ OpenSim/Framework/AssetBase.cs | 22 +++++++++++++++++++ OpenSim/Services/AssetService/AssetService.cs | 1 + 4 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/007_AssetStore.sql diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index d55369a946..5a2af4f9ac 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -161,8 +161,8 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = new MySqlCommand( - "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, data)" + - "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?data)", + "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, data)" + + "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?data)", dbcon); string assetName = asset.Name; @@ -194,6 +194,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("?temporary", asset.Temporary); cmd.Parameters.AddWithValue("?create_time", now); cmd.Parameters.AddWithValue("?access_time", now); + cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); cmd.Parameters.AddWithValue("?data", asset.Data); cmd.ExecuteNonQuery(); cmd.Dispose(); @@ -302,7 +303,7 @@ namespace OpenSim.Data.MySQL using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - MySqlCommand cmd = new MySqlCommand("SELECT name,description,assetType,temporary,id FROM assets LIMIT ?start, ?count", dbcon); + MySqlCommand cmd = new MySqlCommand("SELECT name,description,assetType,temporary,id,asset_flags FROM assets LIMIT ?start, ?count", dbcon); cmd.Parameters.AddWithValue("?start", start); cmd.Parameters.AddWithValue("?count", count); @@ -317,6 +318,7 @@ namespace OpenSim.Data.MySQL metadata.Description = (string)dbReader["description"]; metadata.Type = (sbyte)dbReader["assetType"]; metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. + metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); metadata.FullID = new UUID((string)dbReader["id"]); // Current SHA1s are not stored/computed. diff --git a/OpenSim/Data/MySQL/Resources/007_AssetStore.sql b/OpenSim/Data/MySQL/Resources/007_AssetStore.sql new file mode 100644 index 0000000000..f06121abc1 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/007_AssetStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE assets ADD COLUMN asset_flags INTEGER NOT NULL DEFAULT 0; + +COMMIT; diff --git a/OpenSim/Framework/AssetBase.cs b/OpenSim/Framework/AssetBase.cs index 19ca232208..7ecf198bd8 100644 --- a/OpenSim/Framework/AssetBase.cs +++ b/OpenSim/Framework/AssetBase.cs @@ -33,6 +33,15 @@ using OpenMetaverse; namespace OpenSim.Framework { + [Flags] + public enum AssetFlags : int + { + Normal = 0, + Maptile = 1, + Rewritable = 2, + Collectable = 4 + } + /// /// Asset class. All Assets are reference by this class or a class derived from this class /// @@ -206,6 +215,12 @@ namespace OpenSim.Framework set { m_metadata.Temporary = value; } } + public AssetFlags Flags + { + get { return m_metadata.Flags; } + set { m_metadata.Flags = value; } + } + [XmlIgnore] public AssetMetadata Metadata { @@ -233,6 +248,7 @@ namespace OpenSim.Framework private bool m_local; private bool m_temporary; private string m_creatorid; + private AssetFlags m_flags; public UUID FullID { @@ -330,5 +346,11 @@ namespace OpenSim.Framework get { return m_creatorid; } set { m_creatorid = value; } } + + public AssetFlags Flags + { + get { return m_flags; } + set { m_flags = value; } + } } } diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs index 4e512e729c..2114933ec7 100644 --- a/OpenSim/Services/AssetService/AssetService.cs +++ b/OpenSim/Services/AssetService/AssetService.cs @@ -181,6 +181,7 @@ namespace OpenSim.Services.AssetService MainConsole.Instance.Output(String.Format("Description: {0}", asset.Description)); MainConsole.Instance.Output(String.Format("Type: {0}", asset.Type)); MainConsole.Instance.Output(String.Format("Content-type: {0}", asset.Metadata.ContentType)); + MainConsole.Instance.Output(String.Format("Flags: {0}", asset.Metadata.Flags.ToString())); for (i = 0 ; i < 5 ; i++) {