aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MSSQL/MSSQLAssetData.cs
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-07-24 19:10:32 +0000
committerJustin Clarke Casey2009-07-24 19:10:32 +0000
commita3f4330c8728bf3624f61f831ae8b61358231067 (patch)
tree84fe3c1ebbf6099587c1915378b0b6a06a9a565c /OpenSim/Data/MSSQL/MSSQLAssetData.cs
parent* minor ccc (diff)
downloadopensim-SC_OLD-a3f4330c8728bf3624f61f831ae8b61358231067.zip
opensim-SC_OLD-a3f4330c8728bf3624f61f831ae8b61358231067.tar.gz
opensim-SC_OLD-a3f4330c8728bf3624f61f831ae8b61358231067.tar.bz2
opensim-SC_OLD-a3f4330c8728bf3624f61f831ae8b61358231067.tar.xz
* Apply http://opensimulator.org/mantis/view.php?id=3902
* Restrict asset and inventory name descriptions so as not to overflow MSSQL field lengths * Thanks StrawberryFride
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MSSQL/MSSQLAssetData.cs27
1 files changed, 23 insertions, 4 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs
index ba2b816..1e09c57 100644
--- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs
@@ -60,7 +60,7 @@ namespace OpenSim.Data.MSSQL
60 // [Obsolete("Cannot be default-initialized!")] 60 // [Obsolete("Cannot be default-initialized!")]
61 override public void Initialise() 61 override public void Initialise()
62 { 62 {
63 m_log.Info("[MSSQLUserData]: " + Name + " cannot be default-initialized!"); 63 m_log.Info("[MSSQLAssetData]: " + Name + " cannot be default-initialized!");
64 throw new PluginNotInitialisedException(Name); 64 throw new PluginNotInitialisedException(Name);
65 } 65 }
66 66
@@ -165,12 +165,24 @@ namespace OpenSim.Data.MSSQL
165 VALUES 165 VALUES
166 (@id, @name, @description, @assetType, @local, 166 (@id, @name, @description, @assetType, @local,
167 @temporary, @create_time, @access_time, @data)"; 167 @temporary, @create_time, @access_time, @data)";
168 string assetName = asset.Name;
169 if (asset.Name.Length > 64)
170 {
171 assetName = asset.Name.Substring(0, 64);
172 m_log.Warn("[ASSET DB]: Name field truncated from " + asset.Name.Length.ToString() + " to " + assetName.Length.ToString() + " characters");
173 }
174 string assetDescription = asset.Description;
175 if (asset.Description.Length > 64)
176 {
177 assetDescription = asset.Description.Substring(0, 64);
178 m_log.Warn("[ASSET DB]: Description field truncated from " + asset.Description.Length.ToString() + " to " + assetDescription.Length.ToString() + " characters");
179 }
168 using (AutoClosingSqlCommand command = m_database.Query(sql)) 180 using (AutoClosingSqlCommand command = m_database.Query(sql))
169 { 181 {
170 int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000); 182 int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000);
171 command.Parameters.Add(m_database.CreateParameter("id", asset.FullID)); 183 command.Parameters.Add(m_database.CreateParameter("id", asset.FullID));
172 command.Parameters.Add(m_database.CreateParameter("name", asset.Name)); 184 command.Parameters.Add(m_database.CreateParameter("name", assetName));
173 command.Parameters.Add(m_database.CreateParameter("description", asset.Description)); 185 command.Parameters.Add(m_database.CreateParameter("description", assetDescription));
174 command.Parameters.Add(m_database.CreateParameter("assetType", asset.Type)); 186 command.Parameters.Add(m_database.CreateParameter("assetType", asset.Type));
175 command.Parameters.Add(m_database.CreateParameter("local", asset.Local)); 187 command.Parameters.Add(m_database.CreateParameter("local", asset.Local));
176 command.Parameters.Add(m_database.CreateParameter("temporary", asset.Temporary)); 188 command.Parameters.Add(m_database.CreateParameter("temporary", asset.Temporary));
@@ -178,7 +190,14 @@ namespace OpenSim.Data.MSSQL
178 command.Parameters.Add(m_database.CreateParameter("create_time", now)); 190 command.Parameters.Add(m_database.CreateParameter("create_time", now));
179 command.Parameters.Add(m_database.CreateParameter("data", asset.Data)); 191 command.Parameters.Add(m_database.CreateParameter("data", asset.Data));
180 192
181 command.ExecuteNonQuery(); 193 try
194 {
195 command.ExecuteNonQuery();
196 }
197 catch(Exception e)
198 {
199 m_log.Error("[ASSET DB]: Error inserting item :" + e.Message);
200 }
182 } 201 }
183 } 202 }
184 203