aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/InventoryService/XInventoryService.cs65
1 files changed, 49 insertions, 16 deletions
diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs
index e10e0be..deacd5a 100644
--- a/OpenSim/Services/InventoryService/XInventoryService.cs
+++ b/OpenSim/Services/InventoryService/XInventoryService.cs
@@ -229,10 +229,28 @@ namespace OpenSim.Services.InventoryService
229 public virtual InventoryFolderBase GetFolderForType(UUID principalID, AssetType type) 229 public virtual InventoryFolderBase GetFolderForType(UUID principalID, AssetType type)
230 { 230 {
231// m_log.DebugFormat("[XINVENTORY SERVICE]: Getting folder type {0} for user {1}", type, principalID); 231// m_log.DebugFormat("[XINVENTORY SERVICE]: Getting folder type {0} for user {1}", type, principalID);
232
233 InventoryFolderBase rootFolder = GetRootFolder(principalID);
234
235 if (rootFolder == null)
236 {
237 m_log.WarnFormat(
238 "[XINVENTORY]: Found no root folder for {0} in GetFolderForType() when looking for {1}",
239 principalID, type);
240
241 return null;
242 }
243
244 return GetSystemFolderForType(rootFolder, type);
245 }
246
247 private InventoryFolderBase GetSystemFolderForType(InventoryFolderBase rootFolder, AssetType type)
248 {
249// m_log.DebugFormat("[XINVENTORY SERVICE]: Getting folder type {0} for user {1}", type, principalID);
232 250
233 XInventoryFolder[] folders = m_Database.GetFolders( 251 XInventoryFolder[] folders = m_Database.GetFolders(
234 new string[] { "agentID", "type"}, 252 new string[] { "agentID", "parentFolderID", "type"},
235 new string[] { principalID.ToString(), ((int)type).ToString() }); 253 new string[] { rootFolder.Owner.ToString(), rootFolder.ID.ToString(), ((int)type).ToString() });
236 254
237 if (folders.Length == 0) 255 if (folders.Length == 0)
238 { 256 {
@@ -308,23 +326,38 @@ namespace OpenSim.Services.InventoryService
308 if (check != null) 326 if (check != null)
309 return false; 327 return false;
310 328
311 if (folder.Type == (short)AssetType.Folder 329 if (folder.Type != (short)AssetType.Folder || folder.Type != (short)AssetType.Unknown)
312 || folder.Type == (short)AssetType.Unknown
313 || folder.Type == (short)AssetType.OutfitFolder
314 || folder.Type == (short)AssetType.CallingCard
315 || GetFolderForType(folder.Owner, (AssetType)(folder.Type)) == null)
316 {
317 XInventoryFolder xFolder = ConvertFromOpenSim(folder);
318 return m_Database.StoreFolder(xFolder);
319 }
320 else
321 { 330 {
322 m_log.WarnFormat( 331 InventoryFolderBase rootFolder = GetRootFolder(folder.Owner);
323 "[XINVENTORY]: Folder of type {0} already exists when tried to add {1} to {2} for {3}", 332
324 folder.Type, folder.Name, folder.ParentID, folder.Owner); 333 if (rootFolder == null)
334 {
335 m_log.WarnFormat(
336 "[XINVENTORY]: Found no root folder for {0} in AddFolder() when looking for {1}",
337 folder.Owner, folder.Type);
338
339 return false;
340 }
341
342 // Check we're not trying to add this as a system folder.
343 if (folder.ParentID == rootFolder.ID)
344 {
345 InventoryFolderBase existingSystemFolder
346 = GetSystemFolderForType(rootFolder, (AssetType)folder.Type);
347
348 if (existingSystemFolder != null)
349 {
350 m_log.WarnFormat(
351 "[XINVENTORY]: System folder of type {0} already exists when tried to add {1} to {2} for {3}",
352 folder.Type, folder.Name, folder.ParentID, folder.Owner);
353
354 return false;
355 }
356 }
325 } 357 }
326 358
327 return false; 359 XInventoryFolder xFolder = ConvertFromOpenSim(folder);
360 return m_Database.StoreFolder(xFolder);
328 } 361 }
329 362
330 public virtual bool UpdateFolder(InventoryFolderBase folder) 363 public virtual bool UpdateFolder(InventoryFolderBase folder)