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 exists0.7.4.1
parent
206eccc2b6
commit
30c36a3960
|
@ -230,9 +230,27 @@ namespace OpenSim.Services.InventoryService
|
|||
{
|
||||
// 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,25 +326,40 @@ 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
|
||||
InventoryFolderBase rootFolder = GetRootFolder(folder.Owner);
|
||||
|
||||
if (rootFolder == null)
|
||||
{
|
||||
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);
|
||||
}
|
||||
"[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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
XInventoryFolder xFolder = ConvertFromOpenSim(folder);
|
||||
return m_Database.StoreFolder(xFolder);
|
||||
}
|
||||
|
||||
public virtual bool UpdateFolder(InventoryFolderBase folder)
|
||||
{
|
||||
// m_log.DebugFormat("[XINVENTORY]: Update folder {0} {1} ({2})", folder.Name, folder.Type, folder.ID);
|
||||
|
|
Loading…
Reference in New Issue