save a few lists scaning
parent
1680425f4d
commit
ccaa7a4a8a
|
@ -113,10 +113,7 @@ namespace OpenSim.Capabilities.Handlers
|
|||
continue;
|
||||
}
|
||||
|
||||
// Filter duplicate folder ids that bad viewers may send
|
||||
if (folders.Find(f => f.folder_id == llsdRequest.folder_id) == null)
|
||||
folders.Add(llsdRequest);
|
||||
|
||||
}
|
||||
|
||||
if (folders.Count > 0)
|
||||
|
@ -431,17 +428,10 @@ namespace OpenSim.Capabilities.Handlers
|
|||
|
||||
}
|
||||
|
||||
private void AddLibraryFolders(List<LLSDFetchInventoryDescendents> fetchFolders, List<InventoryCollectionWithDescendents> result)
|
||||
private void AddLibraryFolders(List<LLSDFetchInventoryDescendents> libFolders, List<InventoryCollectionWithDescendents> result)
|
||||
{
|
||||
InventoryFolderImpl fold;
|
||||
if (m_LibraryService != null && m_LibraryService.LibraryRootFolder != null)
|
||||
{
|
||||
List<LLSDFetchInventoryDescendents> libfolders = fetchFolders.FindAll(f => f.owner_id == m_LibraryService.LibraryRootFolder.Owner);
|
||||
fetchFolders.RemoveAll(f => libfolders.Contains(f));
|
||||
|
||||
//m_log.DebugFormat("[XXX]: Found {0} library folders in request", libfolders.Count);
|
||||
|
||||
foreach (LLSDFetchInventoryDescendents f in libfolders)
|
||||
foreach (LLSDFetchInventoryDescendents f in libFolders)
|
||||
{
|
||||
if ((fold = m_LibraryService.LibraryRootFolder.FindFolder(f.folder_id)) != null)
|
||||
{
|
||||
|
@ -461,7 +451,6 @@ namespace OpenSim.Capabilities.Handlers
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<InventoryCollectionWithDescendents> Fetch(List<LLSDFetchInventoryDescendents> fetchFolders, List<UUID> bad_folders)
|
||||
{
|
||||
|
@ -471,50 +460,77 @@ namespace OpenSim.Capabilities.Handlers
|
|||
// FIXME MAYBE: We're not handling sortOrder!
|
||||
|
||||
List<InventoryCollectionWithDescendents> result = new List<InventoryCollectionWithDescendents>();
|
||||
if(fetchFolders.Count <= 0)
|
||||
return result;
|
||||
|
||||
AddLibraryFolders(fetchFolders, result);
|
||||
List<LLSDFetchInventoryDescendents> libFolders = new List<LLSDFetchInventoryDescendents>();
|
||||
List<LLSDFetchInventoryDescendents> otherFolders = new List<LLSDFetchInventoryDescendents>();
|
||||
HashSet<UUID> libIDs = new HashSet<UUID>();
|
||||
HashSet<UUID> otherIDs = new HashSet<UUID>();
|
||||
|
||||
bool dolib = (m_LibraryService != null && m_LibraryService.LibraryRootFolder != null);
|
||||
UUID libOwner = UUID.Zero;
|
||||
if(dolib)
|
||||
libOwner = m_LibraryService.LibraryRootFolder.Owner;
|
||||
|
||||
// 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)
|
||||
// send something.
|
||||
LLSDFetchInventoryDescendents zero = fetchFolders.Find(f => f.folder_id == UUID.Zero);
|
||||
if (zero != null)
|
||||
foreach(LLSDFetchInventoryDescendents f in fetchFolders)
|
||||
{
|
||||
if (f.folder_id == UUID.Zero)
|
||||
{
|
||||
fetchFolders.Remove(zero);
|
||||
InventoryCollectionWithDescendents zeroColl = new InventoryCollectionWithDescendents();
|
||||
zeroColl.Collection = new InventoryCollection();
|
||||
zeroColl.Collection.OwnerID = zero.owner_id;
|
||||
zeroColl.Collection.OwnerID = f.owner_id;
|
||||
zeroColl.Collection.Version = 0;
|
||||
zeroColl.Collection.FolderID = zero.folder_id;
|
||||
zeroColl.Collection.FolderID = f.folder_id;
|
||||
zeroColl.Descendents = 0;
|
||||
result.Add(zeroColl);
|
||||
continue;
|
||||
}
|
||||
if(dolib && f.owner_id == libOwner)
|
||||
{
|
||||
if(libIDs.Contains(f.folder_id))
|
||||
continue;
|
||||
libIDs.Add(f.folder_id);
|
||||
libFolders.Add(f);
|
||||
continue;
|
||||
}
|
||||
if(otherIDs.Contains(f.folder_id))
|
||||
continue;
|
||||
otherIDs.Add(f.folder_id);
|
||||
otherFolders.Add(f);
|
||||
}
|
||||
|
||||
if (fetchFolders.Count > 0)
|
||||
|
||||
if(otherFolders.Count > 0)
|
||||
{
|
||||
UUID[] fids = new UUID[fetchFolders.Count];
|
||||
UUID[] fids = new UUID[otherFolders.Count];
|
||||
int i = 0;
|
||||
foreach (LLSDFetchInventoryDescendents f in fetchFolders)
|
||||
foreach (LLSDFetchInventoryDescendents f in otherFolders)
|
||||
fids[i++] = f.folder_id;
|
||||
|
||||
//m_log.DebugFormat("[XXX]: {0}", string.Join(",", fids));
|
||||
|
||||
InventoryCollection[] fetchedContents = m_InventoryService.GetMultipleFoldersContent(fetchFolders[0].owner_id, fids);
|
||||
InventoryCollection[] fetchedContents = m_InventoryService.GetMultipleFoldersContent(otherFolders[0].owner_id, fids);
|
||||
|
||||
if (fetchedContents == null || (fetchedContents != null && fetchedContents.Length == 0))
|
||||
{
|
||||
m_log.WarnFormat("[WEB FETCH INV DESC HANDLER]: Could not get contents of multiple folders for user {0}", fetchFolders[0].owner_id);
|
||||
foreach (LLSDFetchInventoryDescendents freq in fetchFolders)
|
||||
BadFolder(freq, null, bad_folders);
|
||||
if (fetchedContents == null)
|
||||
return null;
|
||||
}
|
||||
|
||||
if (fetchedContents.Length == 0)
|
||||
{
|
||||
foreach (LLSDFetchInventoryDescendents freq in otherFolders)
|
||||
BadFolder(freq, null, bad_folders);
|
||||
}
|
||||
else
|
||||
{
|
||||
i = 0;
|
||||
// Do some post-processing. May need to fetch more from inv server for links
|
||||
foreach (InventoryCollection contents in fetchedContents)
|
||||
{
|
||||
// Find the original request
|
||||
LLSDFetchInventoryDescendents freq = fetchFolders[i++];
|
||||
LLSDFetchInventoryDescendents freq = otherFolders[i++];
|
||||
|
||||
InventoryCollectionWithDescendents coll = new InventoryCollectionWithDescendents();
|
||||
coll.Collection = contents;
|
||||
|
@ -528,6 +544,12 @@ namespace OpenSim.Capabilities.Handlers
|
|||
result.Add(coll);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(dolib && libFolders.Count > 0)
|
||||
{
|
||||
AddLibraryFolders(libFolders, result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue