diff options
author | Justin Clarke Casey | 2008-05-04 00:06:34 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-05-04 00:06:34 +0000 |
commit | 0f716e3ac4d8af67fed7c23994d2c0f53d8eb2ae (patch) | |
tree | dfcf0200f8b8661635914a97d6162714aa143e90 /OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | |
parent | * Add ability to defer item actions for AddItem() and DeleteItem(). This won... (diff) | |
download | opensim-SC-0f716e3ac4d8af67fed7c23994d2c0f53d8eb2ae.zip opensim-SC-0f716e3ac4d8af67fed7c23994d2c0f53d8eb2ae.tar.gz opensim-SC-0f716e3ac4d8af67fed7c23994d2c0f53d8eb2ae.tar.bz2 opensim-SC-0f716e3ac4d8af67fed7c23994d2c0f53d8eb2ae.tar.xz |
* Simplify CreateFolder() by folding previous special root case into FindFolder()
Diffstat (limited to 'OpenSim/Framework/Communications/Cache/CachedUserInfo.cs')
-rw-r--r-- | OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 89 |
1 files changed, 29 insertions, 60 deletions
diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 6f7c4da..5b84958 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | |||
@@ -239,6 +239,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
239 | else | 239 | else |
240 | { | 240 | { |
241 | InventoryFolderImpl folder = RootFolder.FindFolder(folderInfo.ParentID); | 241 | InventoryFolderImpl folder = RootFolder.FindFolder(folderInfo.ParentID); |
242 | |||
242 | lock (folder.SubFolders) | 243 | lock (folder.SubFolders) |
243 | { | 244 | { |
244 | if (folder != null) | 245 | if (folder != null) |
@@ -323,72 +324,40 @@ namespace OpenSim.Framework.Communications.Cache | |||
323 | 324 | ||
324 | if (HasInventory) | 325 | if (HasInventory) |
325 | { | 326 | { |
326 | if (RootFolder.ID == parentID) | 327 | InventoryFolderImpl parentFolder = RootFolder.FindFolder(parentID); |
328 | |||
329 | if (null == parentFolder) | ||
327 | { | 330 | { |
328 | InventoryFolderImpl createdFolder = RootFolder.CreateNewSubFolder(folderID, folderName, folderType); | 331 | m_log.WarnFormat( |
332 | "[AGENT INVENTORY]: Tried to create folder {0} {1} but the parent {2} does not exist", | ||
333 | folderName, folderID, parentID); | ||
334 | |||
335 | return false; | ||
336 | } | ||
337 | |||
338 | InventoryFolderImpl createdFolder = parentFolder.CreateChildFolder(folderID, folderName, folderType); | ||
329 | 339 | ||
330 | if (createdFolder != null) | 340 | if (createdFolder != null) |
331 | { | 341 | { |
332 | InventoryFolderBase createdBaseFolder = new InventoryFolderBase(); | 342 | InventoryFolderBase createdBaseFolder = new InventoryFolderBase(); |
333 | createdBaseFolder.Owner = createdFolder.Owner; | 343 | createdBaseFolder.Owner = createdFolder.Owner; |
334 | createdBaseFolder.ID = createdFolder.ID; | 344 | createdBaseFolder.ID = createdFolder.ID; |
335 | createdBaseFolder.Name = createdFolder.Name; | 345 | createdBaseFolder.Name = createdFolder.Name; |
336 | createdBaseFolder.ParentID = createdFolder.ParentID; | 346 | createdBaseFolder.ParentID = createdFolder.ParentID; |
337 | createdBaseFolder.Type = createdFolder.Type; | 347 | createdBaseFolder.Type = createdFolder.Type; |
338 | createdBaseFolder.Version = createdFolder.Version; | 348 | createdBaseFolder.Version = createdFolder.Version; |
339 | 349 | ||
340 | m_commsManager.InventoryService.AddFolder(createdBaseFolder); | 350 | m_commsManager.InventoryService.AddFolder(createdBaseFolder); |
341 | 351 | ||
342 | return true; | 352 | return true; |
343 | } | ||
344 | else | ||
345 | { | ||
346 | m_log.WarnFormat( | ||
347 | "[AGENT INVENTORY]: Tried to create folder {0} {1} but the folder already exists", | ||
348 | folderName, folderID); | ||
349 | |||
350 | return false; | ||
351 | } | ||
352 | } | 353 | } |
353 | else | 354 | else |
354 | { | 355 | { |
355 | InventoryFolderImpl folder = RootFolder.FindFolder(parentID); | 356 | m_log.WarnFormat( |
357 | "[AGENT INVENTORY]: Tried to create folder {0} {1} but the folder already exists", | ||
358 | folderName, folderID); | ||
356 | 359 | ||
357 | if (folder != null) | 360 | return false; |
358 | { | ||
359 | InventoryFolderImpl createdFolder = folder.CreateNewSubFolder(folderID, folderName, folderType); | ||
360 | |||
361 | if (createdFolder != null) | ||
362 | { | ||
363 | InventoryFolderBase createdBaseFolder = new InventoryFolderBase(); | ||
364 | createdBaseFolder.Owner = createdFolder.Owner; | ||
365 | createdBaseFolder.ID = createdFolder.ID; | ||
366 | createdBaseFolder.Name = createdFolder.Name; | ||
367 | createdBaseFolder.ParentID = createdFolder.ParentID; | ||
368 | createdBaseFolder.Type = createdFolder.Type; | ||
369 | createdBaseFolder.Version = createdFolder.Version; | ||
370 | |||
371 | m_commsManager.InventoryService.AddFolder(createdBaseFolder); | ||
372 | |||
373 | return true; | ||
374 | } | ||
375 | else | ||
376 | { | ||
377 | m_log.WarnFormat( | ||
378 | "[AGENT INVENTORY]: Tried to create folder {0} {1} but the folder already exists", | ||
379 | folderName, folderID); | ||
380 | |||
381 | return false; | ||
382 | } | ||
383 | } | ||
384 | else | ||
385 | { | ||
386 | m_log.WarnFormat( | ||
387 | "[AGENT INVENTORY]: Could not find parent folder with id {0} in order to create folder {1} {2}", | ||
388 | parentID, folderName, folderID); | ||
389 | |||
390 | return false; | ||
391 | } | ||
392 | } | 361 | } |
393 | } | 362 | } |
394 | else | 363 | else |