cleanup a bit more

httptests
UbitUmarov 2018-01-24 11:43:42 +00:00
parent fc224b444a
commit 22666ad18a
1 changed files with 49 additions and 59 deletions

View File

@ -98,11 +98,11 @@ namespace OpenSim.Capabilities.Handlers
folders.Add(llsdRequest); folders.Add(llsdRequest);
} }
StringBuilder lastresponse = new StringBuilder(1024); if(folders.Count == 0)
lastresponse.Append("<llsd>"); return "<llsd><map><key>folders</key><array /></map></llsd>";
if (folders.Count > 0)
{
List<UUID> bad_folders = new List<UUID>(); List<UUID> bad_folders = new List<UUID>();
List<InventoryCollectionWithDescendents> invcollSet = Fetch(folders, bad_folders); List<InventoryCollectionWithDescendents> invcollSet = Fetch(folders, bad_folders);
//m_log.DebugFormat("[XXX]: Got {0} folders from a request of {1}", invcollSet.Count, folders.Count); //m_log.DebugFormat("[XXX]: Got {0} folders from a request of {1}", invcollSet.Count, folders.Count);
@ -114,6 +114,9 @@ namespace OpenSim.Capabilities.Handlers
#pragma warning restore 0612 #pragma warning restore 0612
} }
StringBuilder lastresponse = new StringBuilder(1024);
lastresponse.Append("<llsd>");
if(invcollSet.Count > 0) if(invcollSet.Count > 0)
{ {
lastresponse.Append("<map><key>folders</key><array>"); lastresponse.Append("<map><key>folders</key><array>");
@ -140,11 +143,6 @@ namespace OpenSim.Capabilities.Handlers
lastresponse.Append("</array></map>"); lastresponse.Append("</array></map>");
} }
lastresponse.Append("</llsd>"); lastresponse.Append("</llsd>");
}
else
{
lastresponse.Append("<map><key>folders</key><array /></map></llsd>");
}
return lastresponse.ToString();; return lastresponse.ToString();;
} }
@ -436,9 +434,6 @@ namespace OpenSim.Capabilities.Handlers
// FIXME MAYBE: We're not handling sortOrder! // FIXME MAYBE: We're not handling sortOrder!
List<InventoryCollectionWithDescendents> result = new List<InventoryCollectionWithDescendents>(); List<InventoryCollectionWithDescendents> result = new List<InventoryCollectionWithDescendents>();
if(fetchFolders.Count <= 0)
return result;
List<LLSDFetchInventoryDescendents> libFolders = new List<LLSDFetchInventoryDescendents>(); List<LLSDFetchInventoryDescendents> libFolders = new List<LLSDFetchInventoryDescendents>();
List<LLSDFetchInventoryDescendents> otherFolders = new List<LLSDFetchInventoryDescendents>(); List<LLSDFetchInventoryDescendents> otherFolders = new List<LLSDFetchInventoryDescendents>();
HashSet<UUID> libIDs = new HashSet<UUID>(); HashSet<UUID> libIDs = new HashSet<UUID>();
@ -452,10 +447,14 @@ namespace OpenSim.Capabilities.Handlers
// Filter folder Zero right here. Some viewers (Firestorm) send request for folder Zero, which doesn't make sense // Filter folder Zero right here. Some viewers (Firestorm) send request for folder Zero, which doesn't make sense
// and can kill the sim (all root folders have parent_id Zero) // and can kill the sim (all root folders have parent_id Zero)
// send something. // send something.
bool doneZeroID = false;
foreach(LLSDFetchInventoryDescendents f in fetchFolders) foreach(LLSDFetchInventoryDescendents f in fetchFolders)
{ {
if (f.folder_id == UUID.Zero) if (f.folder_id == UUID.Zero)
{ {
if(doneZeroID)
continue;
doneZeroID = true;
InventoryCollectionWithDescendents zeroColl = new InventoryCollectionWithDescendents(); InventoryCollectionWithDescendents zeroColl = new InventoryCollectionWithDescendents();
zeroColl.Collection = new InventoryCollection(); zeroColl.Collection = new InventoryCollection();
zeroColl.Collection.OwnerID = f.owner_id; zeroColl.Collection.OwnerID = f.owner_id;
@ -479,17 +478,13 @@ namespace OpenSim.Capabilities.Handlers
otherFolders.Add(f); otherFolders.Add(f);
} }
if(otherFolders.Count > 0) if(otherFolders.Count > 0)
{ {
UUID[] fids = new UUID[otherFolders.Count];
int i = 0; int i = 0;
foreach (LLSDFetchInventoryDescendents f in otherFolders)
fids[i++] = f.folder_id;
//m_log.DebugFormat("[XXX]: {0}", string.Join(",", fids)); //m_log.DebugFormat("[XXX]: {0}", string.Join(",", fids));
InventoryCollection[] fetchedContents = m_InventoryService.GetMultipleFoldersContent(otherFolders[0].owner_id, fids); InventoryCollection[] fetchedContents = m_InventoryService.GetMultipleFoldersContent(otherFolders[0].owner_id, otherIDs.ToArray());
if (fetchedContents == null) if (fetchedContents == null)
return null; return null;
@ -532,34 +527,29 @@ namespace OpenSim.Capabilities.Handlers
private bool BadFolder(LLSDFetchInventoryDescendents freq, InventoryCollection contents, List<UUID> bad_folders) private bool BadFolder(LLSDFetchInventoryDescendents freq, InventoryCollection contents, List<UUID> bad_folders)
{ {
bool bad = false;
if (contents == null) if (contents == null)
{ {
bad_folders.Add(freq.folder_id); bad_folders.Add(freq.folder_id);
bad = true; return true;
} }
// The inventory server isn't sending FolderID in the collection... // The inventory server isn't sending FolderID in the collection...
// Must fetch it individually // Must fetch it individually
else if (contents.FolderID == UUID.Zero) if (contents.FolderID == UUID.Zero)
{ {
InventoryFolderBase containingFolder = m_InventoryService.GetFolder(freq.owner_id, freq.folder_id); InventoryFolderBase containingFolder = m_InventoryService.GetFolder(freq.owner_id, freq.folder_id);
if (containingFolder == null)
if (containingFolder != null)
{ {
m_log.WarnFormat("[WEB FETCH INV DESC HANDLER]: Unable to fetch folder {0}", freq.folder_id);
bad_folders.Add(freq.folder_id);
return true;
}
contents.FolderID = containingFolder.ID; contents.FolderID = containingFolder.ID;
contents.OwnerID = containingFolder.Owner; contents.OwnerID = containingFolder.Owner;
contents.Version = containingFolder.Version; contents.Version = containingFolder.Version;
} }
else
{
m_log.WarnFormat("[WEB FETCH INV DESC HANDLER]: Unable to fetch folder {0}", freq.folder_id);
bad_folders.Add(freq.folder_id);
bad = true;
}
}
return bad; return false;
} }
private void ProcessLinks(LLSDFetchInventoryDescendents freq, InventoryCollectionWithDescendents coll) private void ProcessLinks(LLSDFetchInventoryDescendents freq, InventoryCollectionWithDescendents coll)