diff options
author | UbitUmarov | 2018-01-24 11:43:42 +0000 |
---|---|---|
committer | UbitUmarov | 2018-01-24 11:43:42 +0000 |
commit | 22666ad18a9c9881c41a78ede48bf7d5708f5191 (patch) | |
tree | d5662401eb2fbbc6d4fe57f97d4bc478181ec40a /OpenSim/Capabilities/Handlers/FetchInventory | |
parent | avoid some large unnecessary strings (diff) | |
download | opensim-SC-22666ad18a9c9881c41a78ede48bf7d5708f5191.zip opensim-SC-22666ad18a9c9881c41a78ede48bf7d5708f5191.tar.gz opensim-SC-22666ad18a9c9881c41a78ede48bf7d5708f5191.tar.bz2 opensim-SC-22666ad18a9c9881c41a78ede48bf7d5708f5191.tar.xz |
cleanup a bit more
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs | 104 |
1 files changed, 47 insertions, 57 deletions
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs index 89d9e80..bc92536 100644 --- a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs +++ b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs | |||
@@ -98,53 +98,51 @@ namespace OpenSim.Capabilities.Handlers | |||
98 | folders.Add(llsdRequest); | 98 | folders.Add(llsdRequest); |
99 | } | 99 | } |
100 | 100 | ||
101 | StringBuilder lastresponse = new StringBuilder(1024); | 101 | if(folders.Count == 0) |
102 | lastresponse.Append("<llsd>"); | 102 | return "<llsd><map><key>folders</key><array /></map></llsd>"; |
103 | if (folders.Count > 0) | ||
104 | { | ||
105 | List<UUID> bad_folders = new List<UUID>(); | ||
106 | List<InventoryCollectionWithDescendents> invcollSet = Fetch(folders, bad_folders); | ||
107 | //m_log.DebugFormat("[XXX]: Got {0} folders from a request of {1}", invcollSet.Count, folders.Count); | ||
108 | 103 | ||
109 | if (invcollSet == null) | 104 | List<UUID> bad_folders = new List<UUID>(); |
110 | { | 105 | |
111 | m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Multiple folder fetch failed. Trying old protocol."); | 106 | List<InventoryCollectionWithDescendents> invcollSet = Fetch(folders, bad_folders); |
107 | //m_log.DebugFormat("[XXX]: Got {0} folders from a request of {1}", invcollSet.Count, folders.Count); | ||
108 | |||
109 | if (invcollSet == null) | ||
110 | { | ||
111 | m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Multiple folder fetch failed. Trying old protocol."); | ||
112 | #pragma warning disable 0612 | 112 | #pragma warning disable 0612 |
113 | return FetchInventoryDescendentsRequest(foldersrequested, httpRequest, httpResponse); | 113 | return FetchInventoryDescendentsRequest(foldersrequested, httpRequest, httpResponse); |
114 | #pragma warning restore 0612 | 114 | #pragma warning restore 0612 |
115 | } | 115 | } |
116 | 116 | ||
117 | if(invcollSet.Count > 0) | 117 | StringBuilder lastresponse = new StringBuilder(1024); |
118 | { | 118 | lastresponse.Append("<llsd>"); |
119 | lastresponse.Append("<map><key>folders</key><array>"); | ||
120 | foreach (InventoryCollectionWithDescendents icoll in invcollSet) | ||
121 | { | ||
122 | LLSDInventoryFolderContents thiscontents = contentsToLLSD(icoll.Collection, icoll.Descendents); | ||
123 | lastresponse.Append(LLSDHelpers.SerialiseLLSDReplyNoHeader(thiscontents)); | ||
124 | } | ||
125 | lastresponse.Append("</array></map>"); | ||
126 | } | ||
127 | else | ||
128 | lastresponse.Append("<map><key>folders</key><array /></map>"); | ||
129 | 119 | ||
130 | //m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Bad folders {0}", string.Join(", ", bad_folders)); | 120 | if(invcollSet.Count > 0) |
131 | if(bad_folders.Count > 0) | 121 | { |
122 | lastresponse.Append("<map><key>folders</key><array>"); | ||
123 | foreach (InventoryCollectionWithDescendents icoll in invcollSet) | ||
132 | { | 124 | { |
133 | lastresponse.Append("<map><key>bad_folders</key><array>"); | 125 | LLSDInventoryFolderContents thiscontents = contentsToLLSD(icoll.Collection, icoll.Descendents); |
134 | foreach (UUID bad in bad_folders) | 126 | lastresponse.Append(LLSDHelpers.SerialiseLLSDReplyNoHeader(thiscontents)); |
135 | { | ||
136 | lastresponse.Append("<map><key>folder_id</key><uuid>"); | ||
137 | lastresponse.Append(bad.ToString()); | ||
138 | lastresponse.Append("</uuid><key>error</key><string>Unknown</string></map>"); | ||
139 | } | ||
140 | lastresponse.Append("</array></map>"); | ||
141 | } | 127 | } |
142 | lastresponse.Append("</llsd>"); | 128 | lastresponse.Append("</array></map>"); |
143 | } | 129 | } |
144 | else | 130 | else |
131 | lastresponse.Append("<map><key>folders</key><array /></map>"); | ||
132 | |||
133 | //m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Bad folders {0}", string.Join(", ", bad_folders)); | ||
134 | if(bad_folders.Count > 0) | ||
145 | { | 135 | { |
146 | lastresponse.Append("<map><key>folders</key><array /></map></llsd>"); | 136 | lastresponse.Append("<map><key>bad_folders</key><array>"); |
137 | foreach (UUID bad in bad_folders) | ||
138 | { | ||
139 | lastresponse.Append("<map><key>folder_id</key><uuid>"); | ||
140 | lastresponse.Append(bad.ToString()); | ||
141 | lastresponse.Append("</uuid><key>error</key><string>Unknown</string></map>"); | ||
142 | } | ||
143 | lastresponse.Append("</array></map>"); | ||
147 | } | 144 | } |
145 | lastresponse.Append("</llsd>"); | ||
148 | 146 | ||
149 | return lastresponse.ToString();; | 147 | return lastresponse.ToString();; |
150 | } | 148 | } |
@@ -436,9 +434,6 @@ namespace OpenSim.Capabilities.Handlers | |||
436 | // FIXME MAYBE: We're not handling sortOrder! | 434 | // FIXME MAYBE: We're not handling sortOrder! |
437 | 435 | ||
438 | List<InventoryCollectionWithDescendents> result = new List<InventoryCollectionWithDescendents>(); | 436 | List<InventoryCollectionWithDescendents> result = new List<InventoryCollectionWithDescendents>(); |
439 | if(fetchFolders.Count <= 0) | ||
440 | return result; | ||
441 | |||
442 | List<LLSDFetchInventoryDescendents> libFolders = new List<LLSDFetchInventoryDescendents>(); | 437 | List<LLSDFetchInventoryDescendents> libFolders = new List<LLSDFetchInventoryDescendents>(); |
443 | List<LLSDFetchInventoryDescendents> otherFolders = new List<LLSDFetchInventoryDescendents>(); | 438 | List<LLSDFetchInventoryDescendents> otherFolders = new List<LLSDFetchInventoryDescendents>(); |
444 | HashSet<UUID> libIDs = new HashSet<UUID>(); | 439 | HashSet<UUID> libIDs = new HashSet<UUID>(); |
@@ -452,10 +447,14 @@ namespace OpenSim.Capabilities.Handlers | |||
452 | // Filter folder Zero right here. Some viewers (Firestorm) send request for folder Zero, which doesn't make sense | 447 | // Filter folder Zero right here. Some viewers (Firestorm) send request for folder Zero, which doesn't make sense |
453 | // and can kill the sim (all root folders have parent_id Zero) | 448 | // and can kill the sim (all root folders have parent_id Zero) |
454 | // send something. | 449 | // send something. |
450 | bool doneZeroID = false; | ||
455 | foreach(LLSDFetchInventoryDescendents f in fetchFolders) | 451 | foreach(LLSDFetchInventoryDescendents f in fetchFolders) |
456 | { | 452 | { |
457 | if (f.folder_id == UUID.Zero) | 453 | if (f.folder_id == UUID.Zero) |
458 | { | 454 | { |
455 | if(doneZeroID) | ||
456 | continue; | ||
457 | doneZeroID = true; | ||
459 | InventoryCollectionWithDescendents zeroColl = new InventoryCollectionWithDescendents(); | 458 | InventoryCollectionWithDescendents zeroColl = new InventoryCollectionWithDescendents(); |
460 | zeroColl.Collection = new InventoryCollection(); | 459 | zeroColl.Collection = new InventoryCollection(); |
461 | zeroColl.Collection.OwnerID = f.owner_id; | 460 | zeroColl.Collection.OwnerID = f.owner_id; |
@@ -479,17 +478,13 @@ namespace OpenSim.Capabilities.Handlers | |||
479 | otherFolders.Add(f); | 478 | otherFolders.Add(f); |
480 | } | 479 | } |
481 | 480 | ||
482 | |||
483 | if(otherFolders.Count > 0) | 481 | if(otherFolders.Count > 0) |
484 | { | 482 | { |
485 | UUID[] fids = new UUID[otherFolders.Count]; | ||
486 | int i = 0; | 483 | int i = 0; |
487 | foreach (LLSDFetchInventoryDescendents f in otherFolders) | ||
488 | fids[i++] = f.folder_id; | ||
489 | 484 | ||
490 | //m_log.DebugFormat("[XXX]: {0}", string.Join(",", fids)); | 485 | //m_log.DebugFormat("[XXX]: {0}", string.Join(",", fids)); |
491 | 486 | ||
492 | InventoryCollection[] fetchedContents = m_InventoryService.GetMultipleFoldersContent(otherFolders[0].owner_id, fids); | 487 | InventoryCollection[] fetchedContents = m_InventoryService.GetMultipleFoldersContent(otherFolders[0].owner_id, otherIDs.ToArray()); |
493 | 488 | ||
494 | if (fetchedContents == null) | 489 | if (fetchedContents == null) |
495 | return null; | 490 | return null; |
@@ -532,34 +527,29 @@ namespace OpenSim.Capabilities.Handlers | |||
532 | 527 | ||
533 | private bool BadFolder(LLSDFetchInventoryDescendents freq, InventoryCollection contents, List<UUID> bad_folders) | 528 | private bool BadFolder(LLSDFetchInventoryDescendents freq, InventoryCollection contents, List<UUID> bad_folders) |
534 | { | 529 | { |
535 | bool bad = false; | ||
536 | if (contents == null) | 530 | if (contents == null) |
537 | { | 531 | { |
538 | bad_folders.Add(freq.folder_id); | 532 | bad_folders.Add(freq.folder_id); |
539 | bad = true; | 533 | return true; |
540 | } | 534 | } |
541 | 535 | ||
542 | // The inventory server isn't sending FolderID in the collection... | 536 | // The inventory server isn't sending FolderID in the collection... |
543 | // Must fetch it individually | 537 | // Must fetch it individually |
544 | else if (contents.FolderID == UUID.Zero) | 538 | if (contents.FolderID == UUID.Zero) |
545 | { | 539 | { |
546 | InventoryFolderBase containingFolder = m_InventoryService.GetFolder(freq.owner_id, freq.folder_id); | 540 | InventoryFolderBase containingFolder = m_InventoryService.GetFolder(freq.owner_id, freq.folder_id); |
547 | 541 | if (containingFolder == null) | |
548 | if (containingFolder != null) | ||
549 | { | ||
550 | contents.FolderID = containingFolder.ID; | ||
551 | contents.OwnerID = containingFolder.Owner; | ||
552 | contents.Version = containingFolder.Version; | ||
553 | } | ||
554 | else | ||
555 | { | 542 | { |
556 | m_log.WarnFormat("[WEB FETCH INV DESC HANDLER]: Unable to fetch folder {0}", freq.folder_id); | 543 | m_log.WarnFormat("[WEB FETCH INV DESC HANDLER]: Unable to fetch folder {0}", freq.folder_id); |
557 | bad_folders.Add(freq.folder_id); | 544 | bad_folders.Add(freq.folder_id); |
558 | bad = true; | 545 | return true; |
559 | } | 546 | } |
547 | contents.FolderID = containingFolder.ID; | ||
548 | contents.OwnerID = containingFolder.Owner; | ||
549 | contents.Version = containingFolder.Version; | ||
560 | } | 550 | } |
561 | 551 | ||
562 | return bad; | 552 | return false; |
563 | } | 553 | } |
564 | 554 | ||
565 | private void ProcessLinks(LLSDFetchInventoryDescendents freq, InventoryCollectionWithDescendents coll) | 555 | private void ProcessLinks(LLSDFetchInventoryDescendents freq, InventoryCollectionWithDescendents coll) |