* refactor: Stop exposing InventoryFolderImpl.SubFolders publicly

0.6.1-post-fixes
Justin Clarke Casey 2008-12-11 20:58:11 +00:00
parent 616cf74e73
commit 80e267dcfe
5 changed files with 91 additions and 63 deletions

View File

@ -161,29 +161,27 @@ namespace OpenSim.Framework.Communications.Cache
List<InventoryFolderImpl> resolvedFolders = new List<InventoryFolderImpl>(); // Folders we've resolved with this invocation List<InventoryFolderImpl> resolvedFolders = new List<InventoryFolderImpl>(); // Folders we've resolved with this invocation
foreach (InventoryFolderImpl folder in receivedFolderDictionary[parentFolder.ID]) foreach (InventoryFolderImpl folder in receivedFolderDictionary[parentFolder.ID])
{ {
lock (parentFolder.SubFolders) if (parentFolder.ContainsChildFolder(folder.ID))
{ {
if (parentFolder.SubFolders.ContainsKey(folder.ID)) m_log.WarnFormat(
"[INVENTORY CACHE]: Received folder {0} {1} from inventory service which has already been received",
folder.Name, folder.ID);
}
else
{
if (resolvedFolderDictionary.ContainsKey(folder.ID))
{ {
m_log.WarnFormat( m_log.WarnFormat(
"[INVENTORY CACHE]: Received folder {0} {1} from inventory service which has already been received", "[INVENTORY CACHE]: Received folder {0} {1} from inventory service has already been received but with different parent",
folder.Name, folder.ID); folder.Name, folder.ID);
} }
else else
{ {
if ( resolvedFolderDictionary.ContainsKey( folder.ID ) ) { resolvedFolders.Add(folder);
m_log.WarnFormat( resolvedFolderDictionary[folder.ID] = folder;
"[INVENTORY CACHE]: Received folder {0} {1} from inventory service has already been received but with different parent", parentFolder.AddChildFolder(folder);
folder.Name, folder.ID);
}
else
{
resolvedFolders.Add(folder);
resolvedFolderDictionary[folder.ID] = folder;
parentFolder.SubFolders.Add(folder.ID, folder);
}
} }
} // lock (parentFolder.SubFolders) }
} // foreach (folder in pendingCategorizationFolders[parentFolder.ID]) } // foreach (folder in pendingCategorizationFolders[parentFolder.ID])
receivedFolderDictionary.Remove(parentFolder.ID); receivedFolderDictionary.Remove(parentFolder.ID);
@ -738,20 +736,17 @@ namespace OpenSim.Framework.Communications.Cache
} }
} }
/// <summary>
/// Find an appropriate folder for the given asset type
/// </summary>
/// <param name="type"></param>
/// <returns>null if no appropriate folder exists</returns>
public InventoryFolderImpl FindFolderForType(int type) public InventoryFolderImpl FindFolderForType(int type)
{ {
if (RootFolder == null) if (RootFolder == null)
return null; return null;
lock (RootFolder.SubFolders) return RootFolder.FindFolderForType(type);
{
foreach (InventoryFolderImpl f in RootFolder.SubFolders.Values)
{
if (f.Type == type)
return f;
}
}
return null;
} }
} }

View File

@ -48,7 +48,7 @@ namespace OpenSim.Framework.Communications.Cache
/// <summary> /// <summary>
/// Child folders that are contained in this folder /// Child folders that are contained in this folder
/// </summary> /// </summary>
public Dictionary<UUID, InventoryFolderImpl> SubFolders = new Dictionary<UUID, InventoryFolderImpl>(); protected Dictionary<UUID, InventoryFolderImpl> m_childFolders = new Dictionary<UUID, InventoryFolderImpl>();
// Constructors // Constructors
public InventoryFolderImpl(InventoryFolderBase folderbase) public InventoryFolderImpl(InventoryFolderBase folderbase)
@ -74,9 +74,9 @@ namespace OpenSim.Framework.Communications.Cache
/// <returns>The newly created subfolder. Returns null if the folder already exists</returns> /// <returns>The newly created subfolder. Returns null if the folder already exists</returns>
public InventoryFolderImpl CreateChildFolder(UUID folderID, string folderName, ushort type) public InventoryFolderImpl CreateChildFolder(UUID folderID, string folderName, ushort type)
{ {
lock (SubFolders) lock (m_childFolders)
{ {
if (!SubFolders.ContainsKey(folderID)) if (!m_childFolders.ContainsKey(folderID))
{ {
InventoryFolderImpl subFold = new InventoryFolderImpl(); InventoryFolderImpl subFold = new InventoryFolderImpl();
subFold.Name = folderName; subFold.Name = folderName;
@ -84,7 +84,7 @@ namespace OpenSim.Framework.Communications.Cache
subFold.Type = (short) type; subFold.Type = (short) type;
subFold.ParentID = this.ID; subFold.ParentID = this.ID;
subFold.Owner = Owner; subFold.Owner = Owner;
SubFolders.Add(subFold.ID, subFold); m_childFolders.Add(subFold.ID, subFold);
return subFold; return subFold;
} }
@ -99,13 +99,23 @@ namespace OpenSim.Framework.Communications.Cache
/// <param name="folder"></param> /// <param name="folder"></param>
public void AddChildFolder(InventoryFolderImpl folder) public void AddChildFolder(InventoryFolderImpl folder)
{ {
lock (SubFolders) lock (m_childFolders)
{ {
folder.ParentID = ID; folder.ParentID = ID;
SubFolders[folder.ID] = folder; m_childFolders[folder.ID] = folder;
} }
} }
/// <summary>
/// Does this folder contain the given child folder?
/// </summary>
/// <param name="folderID"></param>
/// <returns></returns>
public bool ContainsChildFolder(UUID folderID)
{
return m_childFolders.ContainsKey(folderID);
}
/// <summary> /// <summary>
/// Get a child folder /// Get a child folder
/// </summary> /// </summary>
@ -115,9 +125,9 @@ namespace OpenSim.Framework.Communications.Cache
{ {
InventoryFolderImpl folder = null; InventoryFolderImpl folder = null;
lock (SubFolders) lock (m_childFolders)
{ {
SubFolders.TryGetValue(folderID, out folder); m_childFolders.TryGetValue(folderID, out folder);
} }
return folder; return folder;
@ -134,12 +144,12 @@ namespace OpenSim.Framework.Communications.Cache
{ {
InventoryFolderImpl removedFolder = null; InventoryFolderImpl removedFolder = null;
lock (SubFolders) lock (m_childFolders)
{ {
if (SubFolders.ContainsKey(folderID)) if (m_childFolders.ContainsKey(folderID))
{ {
removedFolder = SubFolders[folderID]; removedFolder = m_childFolders[folderID];
SubFolders.Remove(folderID); m_childFolders.Remove(folderID);
} }
} }
@ -151,12 +161,12 @@ namespace OpenSim.Framework.Communications.Cache
/// </summary> /// </summary>
public void Purge() public void Purge()
{ {
foreach (InventoryFolderImpl folder in SubFolders.Values) foreach (InventoryFolderImpl folder in m_childFolders.Values)
{ {
folder.Purge(); folder.Purge();
} }
SubFolders.Clear(); m_childFolders.Clear();
Items.Clear(); Items.Clear();
} }
@ -175,9 +185,9 @@ namespace OpenSim.Framework.Communications.Cache
} }
} }
lock (SubFolders) lock (m_childFolders)
{ {
foreach (InventoryFolderImpl folder in SubFolders.Values) foreach (InventoryFolderImpl folder in m_childFolders.Values)
{ {
InventoryItemBase item = folder.FindItem(itemID); InventoryItemBase item = folder.FindItem(itemID);
@ -202,9 +212,9 @@ namespace OpenSim.Framework.Communications.Cache
} }
} }
lock (SubFolders) lock (m_childFolders)
{ {
foreach (InventoryFolderImpl folder in SubFolders.Values) foreach (InventoryFolderImpl folder in m_childFolders.Values)
{ {
InventoryItemBase item = folder.FindAsset(assetID); InventoryItemBase item = folder.FindAsset(assetID);
@ -236,9 +246,9 @@ namespace OpenSim.Framework.Communications.Cache
} }
} }
lock (SubFolders) lock (m_childFolders)
{ {
foreach (InventoryFolderImpl folder in SubFolders.Values) foreach (InventoryFolderImpl folder in m_childFolders.Values)
{ {
found = folder.DeleteItem(itemID); found = folder.DeleteItem(itemID);
@ -262,9 +272,9 @@ namespace OpenSim.Framework.Communications.Cache
if (folderID == ID) if (folderID == ID)
return this; return this;
lock (SubFolders) lock (m_childFolders)
{ {
foreach (InventoryFolderImpl folder in SubFolders.Values) foreach (InventoryFolderImpl folder in m_childFolders.Values)
{ {
InventoryFolderImpl returnFolder = folder.FindFolder(folderID); InventoryFolderImpl returnFolder = folder.FindFolder(folderID);
@ -276,6 +286,25 @@ namespace OpenSim.Framework.Communications.Cache
return null; return null;
} }
/// <summary>
/// Look through all child subfolders for a folder marked as one for a particular asset type, and return it.
/// </summary>
/// <param name="type"></param>
/// <returns>Returns null if no such folder is found</returns>
public InventoryFolderImpl FindFolderForType(int type)
{
lock (m_childFolders)
{
foreach (InventoryFolderImpl f in m_childFolders.Values)
{
if (f.Type == type)
return f;
}
}
return null;
}
/// <summary> /// <summary>
/// Find a folder given a PATH_DELIMITOR delimited path starting from this folder /// Find a folder given a PATH_DELIMITOR delimited path starting from this folder
/// ///
@ -297,9 +326,9 @@ namespace OpenSim.Framework.Communications.Cache
string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None);
lock (SubFolders) lock (m_childFolders)
{ {
foreach (InventoryFolderImpl folder in SubFolders.Values) foreach (InventoryFolderImpl folder in m_childFolders.Values)
{ {
if (folder.Name == components[0]) if (folder.Name == components[0])
if (components.Length > 1) if (components.Length > 1)
@ -344,9 +373,9 @@ namespace OpenSim.Framework.Communications.Cache
} }
else else
{ {
lock (SubFolders) lock (m_childFolders)
{ {
foreach (InventoryFolderImpl folder in SubFolders.Values) foreach (InventoryFolderImpl folder in m_childFolders.Values)
{ {
if (folder.Name == components[0]) if (folder.Name == components[0])
return folder.FindItemByPath(components[1]); return folder.FindItemByPath(components[1]);
@ -385,9 +414,9 @@ namespace OpenSim.Framework.Communications.Cache
{ {
List<InventoryFolderBase> folderList = new List<InventoryFolderBase>(); List<InventoryFolderBase> folderList = new List<InventoryFolderBase>();
lock (SubFolders) lock (m_childFolders)
{ {
foreach (InventoryFolderBase folder in SubFolders.Values) foreach (InventoryFolderBase folder in m_childFolders.Values)
{ {
folderList.Add(folder); folderList.Add(folder);
} }
@ -400,9 +429,9 @@ namespace OpenSim.Framework.Communications.Cache
{ {
List<InventoryFolderImpl> folderList = new List<InventoryFolderImpl>(); List<InventoryFolderImpl> folderList = new List<InventoryFolderImpl>();
lock (SubFolders) lock (m_childFolders)
{ {
foreach (InventoryFolderImpl folder in SubFolders.Values) foreach (InventoryFolderImpl folder in m_childFolders.Values)
{ {
folderList.Add(folder); folderList.Add(folder);
} }
@ -421,7 +450,7 @@ namespace OpenSim.Framework.Communications.Cache
{ {
int total = Items.Count; int total = Items.Count;
foreach (InventoryFolderImpl folder in SubFolders.Values) foreach (InventoryFolderImpl folder in m_childFolders.Values)
{ {
total = total + folder.TotalCount; total = total + folder.TotalCount;
} }

View File

@ -142,7 +142,7 @@ namespace OpenSim.Framework.Communications.Cache
InventoryFolderImpl parentFolder = libraryFolders[folderInfo.ParentID]; InventoryFolderImpl parentFolder = libraryFolders[folderInfo.ParentID];
libraryFolders.Add(folderInfo.ID, folderInfo); libraryFolders.Add(folderInfo.ID, folderInfo);
parentFolder.SubFolders.Add(folderInfo.ID, folderInfo); parentFolder.AddChildFolder(folderInfo);
// m_log.InfoFormat("[LIBRARY INVENTORY]: Adding folder {0} ({1})", folderInfo.name, folderInfo.folderID); // m_log.InfoFormat("[LIBRARY INVENTORY]: Adding folder {0} ({1})", folderInfo.name, folderInfo.folderID);
} }

View File

@ -106,11 +106,11 @@ namespace OpenSim.Framework.Communications.Tests
CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010");
Assert.That(userInfo.RootFolder.SubFolders.ContainsKey(folderId), Is.False); Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False);
userInfo.CreateFolder("testFolder", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID); userInfo.CreateFolder("testFolder", folderId, (ushort)AssetType.Animation, userInfo.RootFolder.ID);
Assert.That(inventoryDataPlugin.getInventoryFolder(folderId), Is.Not.Null); Assert.That(inventoryDataPlugin.getInventoryFolder(folderId), Is.Not.Null);
Assert.That(userInfo.RootFolder.SubFolders.ContainsKey(folderId), Is.True); Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.True);
} }
/// <summary> /// <summary>

View File

@ -1884,10 +1884,14 @@ namespace OpenSim.Region.Environment.Scenes
{ {
if (!grp.HasGroupChanged) if (!grp.HasGroupChanged)
{ {
m_log.InfoFormat("[ATTACHMENT] Save request for {0} which is unchanged", grp.UUID.ToString()); m_log.InfoFormat("[ATTACHMENT]: Save request for {0} which is unchanged", grp.UUID);
return; return;
} }
m_log.InfoFormat("[ATTACHMENT] Updating asset for attachment {0}, attachpoint {1}", grp.UUID.ToString(), grp.GetAttachmentPoint());
m_log.InfoFormat(
"[ATTACHMENT]: Updating asset for attachment {0}, attachpoint {1}",
grp.UUID, grp.GetAttachmentPoint());
string sceneObjectXml = objectGroup.ToXmlString(); string sceneObjectXml = objectGroup.ToXmlString();
CachedUserInfo userInfo = CachedUserInfo userInfo =
@ -1917,7 +1921,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
else else
{ {
foreach (InventoryFolderImpl subfld in fld.SubFolders.Values) foreach (InventoryFolderImpl subfld in fld.RequestListOfFolderImpls())
{ {
searchfolders.Enqueue(subfld); searchfolders.Enqueue(subfld);
} }