diff options
author | UbitUmarov | 2016-12-06 10:26:36 +0000 |
---|---|---|
committer | UbitUmarov | 2016-12-06 10:26:36 +0000 |
commit | ccaa7a4a8ae986a5c6c77e03245159ee8bc1550f (patch) | |
tree | 02dc94730a87e11f696fb8906ccd858062903efc /OpenSim/Capabilities/Handlers/FetchInventory | |
parent | Merge branch 'master' into httptests (diff) | |
download | opensim-SC-ccaa7a4a8ae986a5c6c77e03245159ee8bc1550f.zip opensim-SC-ccaa7a4a8ae986a5c6c77e03245159ee8bc1550f.tar.gz opensim-SC-ccaa7a4a8ae986a5c6c77e03245159ee8bc1550f.tar.bz2 opensim-SC-ccaa7a4a8ae986a5c6c77e03245159ee8bc1550f.tar.xz |
save a few lists scaning
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs | 138 |
1 files changed, 80 insertions, 58 deletions
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs index 2fb1c63..e3d285a 100644 --- a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs +++ b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs | |||
@@ -113,10 +113,7 @@ namespace OpenSim.Capabilities.Handlers | |||
113 | continue; | 113 | continue; |
114 | } | 114 | } |
115 | 115 | ||
116 | // Filter duplicate folder ids that bad viewers may send | 116 | folders.Add(llsdRequest); |
117 | if (folders.Find(f => f.folder_id == llsdRequest.folder_id) == null) | ||
118 | folders.Add(llsdRequest); | ||
119 | |||
120 | } | 117 | } |
121 | 118 | ||
122 | if (folders.Count > 0) | 119 | if (folders.Count > 0) |
@@ -431,34 +428,26 @@ namespace OpenSim.Capabilities.Handlers | |||
431 | 428 | ||
432 | } | 429 | } |
433 | 430 | ||
434 | private void AddLibraryFolders(List<LLSDFetchInventoryDescendents> fetchFolders, List<InventoryCollectionWithDescendents> result) | 431 | private void AddLibraryFolders(List<LLSDFetchInventoryDescendents> libFolders, List<InventoryCollectionWithDescendents> result) |
435 | { | 432 | { |
436 | InventoryFolderImpl fold; | 433 | InventoryFolderImpl fold; |
437 | if (m_LibraryService != null && m_LibraryService.LibraryRootFolder != null) | 434 | foreach (LLSDFetchInventoryDescendents f in libFolders) |
438 | { | 435 | { |
439 | List<LLSDFetchInventoryDescendents> libfolders = fetchFolders.FindAll(f => f.owner_id == m_LibraryService.LibraryRootFolder.Owner); | 436 | if ((fold = m_LibraryService.LibraryRootFolder.FindFolder(f.folder_id)) != null) |
440 | fetchFolders.RemoveAll(f => libfolders.Contains(f)); | ||
441 | |||
442 | //m_log.DebugFormat("[XXX]: Found {0} library folders in request", libfolders.Count); | ||
443 | |||
444 | foreach (LLSDFetchInventoryDescendents f in libfolders) | ||
445 | { | 437 | { |
446 | if ((fold = m_LibraryService.LibraryRootFolder.FindFolder(f.folder_id)) != null) | 438 | InventoryCollectionWithDescendents ret = new InventoryCollectionWithDescendents(); |
447 | { | 439 | ret.Collection = new InventoryCollection(); |
448 | InventoryCollectionWithDescendents ret = new InventoryCollectionWithDescendents(); | ||
449 | ret.Collection = new InventoryCollection(); | ||
450 | // ret.Collection.Folders = new List<InventoryFolderBase>(); | 440 | // ret.Collection.Folders = new List<InventoryFolderBase>(); |
451 | ret.Collection.Folders = fold.RequestListOfFolders(); | 441 | ret.Collection.Folders = fold.RequestListOfFolders(); |
452 | ret.Collection.Items = fold.RequestListOfItems(); | 442 | ret.Collection.Items = fold.RequestListOfItems(); |
453 | ret.Collection.OwnerID = m_LibraryService.LibraryRootFolder.Owner; | 443 | ret.Collection.OwnerID = m_LibraryService.LibraryRootFolder.Owner; |
454 | ret.Collection.FolderID = f.folder_id; | 444 | ret.Collection.FolderID = f.folder_id; |
455 | ret.Collection.Version = fold.Version; | 445 | ret.Collection.Version = fold.Version; |
456 | 446 | ||
457 | ret.Descendents = ret.Collection.Items.Count + ret.Collection.Folders.Count; | 447 | ret.Descendents = ret.Collection.Items.Count + ret.Collection.Folders.Count; |
458 | result.Add(ret); | 448 | result.Add(ret); |
459 | 449 | ||
460 | //m_log.DebugFormat("[XXX]: Added libfolder {0} ({1}) {2}", ret.Collection.FolderID, ret.Collection.OwnerID); | 450 | //m_log.DebugFormat("[XXX]: Added libfolder {0} ({1}) {2}", ret.Collection.FolderID, ret.Collection.OwnerID); |
461 | } | ||
462 | } | 451 | } |
463 | } | 452 | } |
464 | } | 453 | } |
@@ -471,64 +460,97 @@ namespace OpenSim.Capabilities.Handlers | |||
471 | // FIXME MAYBE: We're not handling sortOrder! | 460 | // FIXME MAYBE: We're not handling sortOrder! |
472 | 461 | ||
473 | List<InventoryCollectionWithDescendents> result = new List<InventoryCollectionWithDescendents>(); | 462 | List<InventoryCollectionWithDescendents> result = new List<InventoryCollectionWithDescendents>(); |
463 | if(fetchFolders.Count <= 0) | ||
464 | return result; | ||
465 | |||
466 | List<LLSDFetchInventoryDescendents> libFolders = new List<LLSDFetchInventoryDescendents>(); | ||
467 | List<LLSDFetchInventoryDescendents> otherFolders = new List<LLSDFetchInventoryDescendents>(); | ||
468 | HashSet<UUID> libIDs = new HashSet<UUID>(); | ||
469 | HashSet<UUID> otherIDs = new HashSet<UUID>(); | ||
474 | 470 | ||
475 | AddLibraryFolders(fetchFolders, result); | 471 | bool dolib = (m_LibraryService != null && m_LibraryService.LibraryRootFolder != null); |
472 | UUID libOwner = UUID.Zero; | ||
473 | if(dolib) | ||
474 | libOwner = m_LibraryService.LibraryRootFolder.Owner; | ||
476 | 475 | ||
477 | // Filter folder Zero right here. Some viewers (Firestorm) send request for folder Zero, which doesn't make sense | 476 | // Filter folder Zero right here. Some viewers (Firestorm) send request for folder Zero, which doesn't make sense |
478 | // and can kill the sim (all root folders have parent_id Zero) | 477 | // and can kill the sim (all root folders have parent_id Zero) |
479 | // send something. | 478 | // send something. |
480 | LLSDFetchInventoryDescendents zero = fetchFolders.Find(f => f.folder_id == UUID.Zero); | 479 | foreach(LLSDFetchInventoryDescendents f in fetchFolders) |
481 | if (zero != null) | ||
482 | { | 480 | { |
483 | fetchFolders.Remove(zero); | 481 | if (f.folder_id == UUID.Zero) |
484 | InventoryCollectionWithDescendents zeroColl = new InventoryCollectionWithDescendents(); | 482 | { |
485 | zeroColl.Collection = new InventoryCollection(); | 483 | InventoryCollectionWithDescendents zeroColl = new InventoryCollectionWithDescendents(); |
486 | zeroColl.Collection.OwnerID = zero.owner_id; | 484 | zeroColl.Collection = new InventoryCollection(); |
487 | zeroColl.Collection.Version = 0; | 485 | zeroColl.Collection.OwnerID = f.owner_id; |
488 | zeroColl.Collection.FolderID = zero.folder_id; | 486 | zeroColl.Collection.Version = 0; |
489 | zeroColl.Descendents = 0; | 487 | zeroColl.Collection.FolderID = f.folder_id; |
490 | result.Add(zeroColl); | 488 | zeroColl.Descendents = 0; |
489 | result.Add(zeroColl); | ||
490 | continue; | ||
491 | } | ||
492 | if(dolib && f.owner_id == libOwner) | ||
493 | { | ||
494 | if(libIDs.Contains(f.folder_id)) | ||
495 | continue; | ||
496 | libIDs.Add(f.folder_id); | ||
497 | libFolders.Add(f); | ||
498 | continue; | ||
499 | } | ||
500 | if(otherIDs.Contains(f.folder_id)) | ||
501 | continue; | ||
502 | otherIDs.Add(f.folder_id); | ||
503 | otherFolders.Add(f); | ||
491 | } | 504 | } |
492 | 505 | ||
493 | if (fetchFolders.Count > 0) | 506 | |
494 | { | 507 | if(otherFolders.Count > 0) |
495 | UUID[] fids = new UUID[fetchFolders.Count]; | 508 | { |
509 | UUID[] fids = new UUID[otherFolders.Count]; | ||
496 | int i = 0; | 510 | int i = 0; |
497 | foreach (LLSDFetchInventoryDescendents f in fetchFolders) | 511 | foreach (LLSDFetchInventoryDescendents f in otherFolders) |
498 | fids[i++] = f.folder_id; | 512 | fids[i++] = f.folder_id; |
499 | 513 | ||
500 | //m_log.DebugFormat("[XXX]: {0}", string.Join(",", fids)); | 514 | //m_log.DebugFormat("[XXX]: {0}", string.Join(",", fids)); |
501 | 515 | ||
502 | InventoryCollection[] fetchedContents = m_InventoryService.GetMultipleFoldersContent(fetchFolders[0].owner_id, fids); | 516 | InventoryCollection[] fetchedContents = m_InventoryService.GetMultipleFoldersContent(otherFolders[0].owner_id, fids); |
503 | 517 | ||
504 | if (fetchedContents == null || (fetchedContents != null && fetchedContents.Length == 0)) | 518 | if (fetchedContents == null) |
519 | return null; | ||
520 | |||
521 | if (fetchedContents.Length == 0) | ||
505 | { | 522 | { |
506 | m_log.WarnFormat("[WEB FETCH INV DESC HANDLER]: Could not get contents of multiple folders for user {0}", fetchFolders[0].owner_id); | 523 | foreach (LLSDFetchInventoryDescendents freq in otherFolders) |
507 | foreach (LLSDFetchInventoryDescendents freq in fetchFolders) | ||
508 | BadFolder(freq, null, bad_folders); | 524 | BadFolder(freq, null, bad_folders); |
509 | return null; | ||
510 | } | 525 | } |
511 | 526 | else | |
512 | i = 0; | ||
513 | // Do some post-processing. May need to fetch more from inv server for links | ||
514 | foreach (InventoryCollection contents in fetchedContents) | ||
515 | { | 527 | { |
516 | // Find the original request | 528 | i = 0; |
517 | LLSDFetchInventoryDescendents freq = fetchFolders[i++]; | 529 | // Do some post-processing. May need to fetch more from inv server for links |
530 | foreach (InventoryCollection contents in fetchedContents) | ||
531 | { | ||
532 | // Find the original request | ||
533 | LLSDFetchInventoryDescendents freq = otherFolders[i++]; | ||
518 | 534 | ||
519 | InventoryCollectionWithDescendents coll = new InventoryCollectionWithDescendents(); | 535 | InventoryCollectionWithDescendents coll = new InventoryCollectionWithDescendents(); |
520 | coll.Collection = contents; | 536 | coll.Collection = contents; |
521 | 537 | ||
522 | if (BadFolder(freq, contents, bad_folders)) | 538 | if (BadFolder(freq, contents, bad_folders)) |
523 | continue; | 539 | continue; |
524 | 540 | ||
525 | // Next: link management | 541 | // Next: link management |
526 | ProcessLinks(freq, coll); | 542 | ProcessLinks(freq, coll); |
527 | 543 | ||
528 | result.Add(coll); | 544 | result.Add(coll); |
545 | } | ||
529 | } | 546 | } |
530 | } | 547 | } |
531 | 548 | ||
549 | if(dolib && libFolders.Count > 0) | ||
550 | { | ||
551 | AddLibraryFolders(libFolders, result); | ||
552 | } | ||
553 | |||
532 | return result; | 554 | return result; |
533 | } | 555 | } |
534 | 556 | ||