aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
authorMelanie2012-08-25 18:08:10 +0100
committerMelanie2012-08-25 18:08:10 +0100
commit007a45aa76af0029a43b634a0a44a48f15ea5654 (patch)
tree5a5202f11b7b54953ea462d70a25dec77502f5eb /OpenSim/Services
parentMerge branch 'master' into careminster (diff)
parentFollowing on from f8a89a79, do not allow more than one 'type' folder (e.g. ca... (diff)
downloadopensim-SC-007a45aa76af0029a43b634a0a44a48f15ea5654.zip
opensim-SC-007a45aa76af0029a43b634a0a44a48f15ea5654.tar.gz
opensim-SC-007a45aa76af0029a43b634a0a44a48f15ea5654.tar.bz2
opensim-SC-007a45aa76af0029a43b634a0a44a48f15ea5654.tar.xz
Merge commit 'a0d178b284050df64d0eb5b9728565fd72615c22' into careminster
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/InventoryService/XInventoryService.cs64
1 files changed, 49 insertions, 15 deletions
diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs
index 7518b86..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,22 +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 || GetFolderForType(folder.Owner, (AssetType)(folder.Type)) == null)
315 {
316 XInventoryFolder xFolder = ConvertFromOpenSim(folder);
317 return m_Database.StoreFolder(xFolder);
318 }
319 else
320 { 330 {
321 m_log.WarnFormat( 331 InventoryFolderBase rootFolder = GetRootFolder(folder.Owner);
322 "[XINVENTORY]: Folder of type {0} already exists when tried to add {1} to {2} for {3}", 332
323 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 }
324 } 357 }
325 358
326 return false; 359 XInventoryFolder xFolder = ConvertFromOpenSim(folder);
360 return m_Database.StoreFolder(xFolder);
327 } 361 }
328 362
329 public virtual bool UpdateFolder(InventoryFolderBase folder) 363 public virtual bool UpdateFolder(InventoryFolderBase folder)