Following on from f8a89a79, do not allow more than one 'type' folder (e.g. calling cards) to be created in the base "My Inventory" user folder.

This is to accomodate situations where viewers will create more than one 'type' subfolder (e.g. calling cards)
But at the same time to prevent multiple such 'system' folders (those in the base "My Inventory" user folder).
This also makes GetFolderForType() only return a folder in the base "My Inventory" folder, if such a type folder exists
integration
Justin Clark-Casey (justincc) 2012-08-25 02:00:17 +01:00
parent f8a89a79eb
commit a0d178b284
1 changed files with 49 additions and 16 deletions

View File

@ -229,10 +229,28 @@ namespace OpenSim.Services.InventoryService
public virtual InventoryFolderBase GetFolderForType(UUID principalID, AssetType type)
{
// m_log.DebugFormat("[XINVENTORY SERVICE]: Getting folder type {0} for user {1}", type, principalID);
InventoryFolderBase rootFolder = GetRootFolder(principalID);
if (rootFolder == null)
{
m_log.WarnFormat(
"[XINVENTORY]: Found no root folder for {0} in GetFolderForType() when looking for {1}",
principalID, type);
return null;
}
return GetSystemFolderForType(rootFolder, type);
}
private InventoryFolderBase GetSystemFolderForType(InventoryFolderBase rootFolder, AssetType type)
{
// m_log.DebugFormat("[XINVENTORY SERVICE]: Getting folder type {0} for user {1}", type, principalID);
XInventoryFolder[] folders = m_Database.GetFolders(
new string[] { "agentID", "type"},
new string[] { principalID.ToString(), ((int)type).ToString() });
new string[] { "agentID", "parentFolderID", "type"},
new string[] { rootFolder.Owner.ToString(), rootFolder.ID.ToString(), ((int)type).ToString() });
if (folders.Length == 0)
{
@ -308,23 +326,38 @@ namespace OpenSim.Services.InventoryService
if (check != null)
return false;
if (folder.Type == (short)AssetType.Folder
|| folder.Type == (short)AssetType.Unknown
|| folder.Type == (short)AssetType.OutfitFolder
|| folder.Type == (short)AssetType.CallingCard
|| GetFolderForType(folder.Owner, (AssetType)(folder.Type)) == null)
if (folder.Type != (short)AssetType.Folder || folder.Type != (short)AssetType.Unknown)
{
XInventoryFolder xFolder = ConvertFromOpenSim(folder);
return m_Database.StoreFolder(xFolder);
}
else
{
m_log.WarnFormat(
"[XINVENTORY]: Folder of type {0} already exists when tried to add {1} to {2} for {3}",
folder.Type, folder.Name, folder.ParentID, folder.Owner);
InventoryFolderBase rootFolder = GetRootFolder(folder.Owner);
if (rootFolder == null)
{
m_log.WarnFormat(
"[XINVENTORY]: Found no root folder for {0} in AddFolder() when looking for {1}",
folder.Owner, folder.Type);
return false;
}
// Check we're not trying to add this as a system folder.
if (folder.ParentID == rootFolder.ID)
{
InventoryFolderBase existingSystemFolder
= GetSystemFolderForType(rootFolder, (AssetType)folder.Type);
if (existingSystemFolder != null)
{
m_log.WarnFormat(
"[XINVENTORY]: System folder of type {0} already exists when tried to add {1} to {2} for {3}",
folder.Type, folder.Name, folder.ParentID, folder.Owner);
return false;
}
}
}
return false;
XInventoryFolder xFolder = ConvertFromOpenSim(folder);
return m_Database.StoreFolder(xFolder);
}
public virtual bool UpdateFolder(InventoryFolderBase folder)