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.
slimupdates2
Melanie 2010-05-09 17:02:22 +01:00
parent c1fe07b022
commit 9b22393cf3
4 changed files with 33 additions and 3 deletions

View File

@ -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.

View File

@ -0,0 +1,5 @@
BEGIN;
ALTER TABLE assets ADD COLUMN asset_flags INTEGER NOT NULL DEFAULT 0;
COMMIT;

View File

@ -33,6 +33,15 @@ using OpenMetaverse;
namespace OpenSim.Framework
{
[Flags]
public enum AssetFlags : int
{
Normal = 0,
Maptile = 1,
Rewritable = 2,
Collectable = 4
}
/// <summary>
/// Asset class. All Assets are reference by this class or a class derived from this class
/// </summary>
@ -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; }
}
}
}

View File

@ -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++)
{