This patch fixes mantis 105. Basically, it stops the index exception when
no root folder is found and it makes the user server wait longer for the inventory server to do its work. From Justin Casey (IBM)afrisby
parent
5e08911400
commit
0855066968
|
@ -83,9 +83,11 @@ namespace OpenSim.Framework.Communications
|
||||||
public List<InventoryFolderBase> RequestFirstLevelFolders(LLUUID userID)
|
public List<InventoryFolderBase> RequestFirstLevelFolders(LLUUID userID)
|
||||||
{
|
{
|
||||||
List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>();
|
List<InventoryFolderBase> inventoryList = new List<InventoryFolderBase>();
|
||||||
|
InventoryFolderBase rootFolder = null;
|
||||||
|
|
||||||
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
|
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
|
||||||
{
|
{
|
||||||
InventoryFolderBase rootFolder = plugin.Value.getUserRootFolder(userID);
|
rootFolder = plugin.Value.getUserRootFolder(userID);
|
||||||
if (rootFolder != null)
|
if (rootFolder != null)
|
||||||
{
|
{
|
||||||
inventoryList = plugin.Value.getInventoryFolders(rootFolder.folderID);
|
inventoryList = plugin.Value.getInventoryFolders(rootFolder.folderID);
|
||||||
|
@ -93,6 +95,13 @@ namespace OpenSim.Framework.Communications
|
||||||
return inventoryList;
|
return inventoryList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null == rootFolder)
|
||||||
|
{
|
||||||
|
MainLog.Instance.Warn(
|
||||||
|
"INVENTORY", "Could not find a root folder belonging to user with ID " + userID);
|
||||||
|
}
|
||||||
|
|
||||||
return inventoryList;
|
return inventoryList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -201,11 +201,7 @@ namespace OpenSim.Framework.Data.MSSQL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
// see InventoryItemBase.getUserRootFolder
|
||||||
/// Returns the users inventory root folder.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="user"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public InventoryFolderBase getUserRootFolder(LLUUID user)
|
public InventoryFolderBase getUserRootFolder(LLUUID user)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -224,8 +220,14 @@ namespace OpenSim.Framework.Data.MSSQL
|
||||||
items.Add(readInventoryFolder(reader));
|
items.Add(readInventoryFolder(reader));
|
||||||
|
|
||||||
InventoryFolderBase rootFolder = null;
|
InventoryFolderBase rootFolder = null;
|
||||||
|
|
||||||
|
// There should only ever be one root folder for a user. However, if there's more
|
||||||
|
// than one we'll simply use the first one rather than failing. It would be even
|
||||||
|
// nicer to print some message to this effect, but this feels like it's too low a
|
||||||
|
// to put such a message out, and it's too minor right now to spare the time to
|
||||||
|
// suitably refactor.
|
||||||
if (items.Count > 0) {
|
if (items.Count > 0) {
|
||||||
rootFolder = items[0]; //should only be one folder with parent set to zero (the root one).
|
rootFolder = items[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.Close();
|
reader.Close();
|
||||||
|
|
|
@ -211,11 +211,7 @@ namespace OpenSim.Framework.Data.MySQL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
// see InventoryItemBase.getUserRootFolder
|
||||||
/// Returns the users inventory root folder.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="user"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public InventoryFolderBase getUserRootFolder(LLUUID user)
|
public InventoryFolderBase getUserRootFolder(LLUUID user)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -235,8 +231,18 @@ namespace OpenSim.Framework.Data.MySQL
|
||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
items.Add(readInventoryFolder(reader));
|
items.Add(readInventoryFolder(reader));
|
||||||
|
|
||||||
InventoryFolderBase rootFolder = items[0];
|
InventoryFolderBase rootFolder = null;
|
||||||
//should only be one folder with parent set to zero (the root one).
|
|
||||||
|
// There should only ever be one root folder for a user. However, if there's more
|
||||||
|
// than one we'll simply use the first one rather than failing. It would be even
|
||||||
|
// nicer to print some message to this effect, but this feels like it's too low a
|
||||||
|
// to put such a message out, and it's too minor right now to spare the time to
|
||||||
|
// suitably refactor.
|
||||||
|
if (items.Count > 0)
|
||||||
|
{
|
||||||
|
rootFolder = items[0];
|
||||||
|
}
|
||||||
|
|
||||||
reader.Close();
|
reader.Close();
|
||||||
result.Dispose();
|
result.Dispose();
|
||||||
|
|
||||||
|
@ -252,7 +258,9 @@ namespace OpenSim.Framework.Data.MySQL
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a list of folders in a users inventory contained within the specified folder
|
/// Return a list of folders in a users inventory contained within the specified folder.
|
||||||
|
/// This method is only used in tests - in normal operation the user always have one,
|
||||||
|
/// and only one, root folder.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parentID">The folder to search</param>
|
/// <param name="parentID">The folder to search</param>
|
||||||
/// <returns>A list of inventory folders</returns>
|
/// <returns>A list of inventory folders</returns>
|
||||||
|
|
|
@ -226,11 +226,7 @@ namespace OpenSim.Framework.Data.SQLite
|
||||||
return new List<InventoryFolderBase>();
|
return new List<InventoryFolderBase>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
// see InventoryItemBase.getUserRootFolder
|
||||||
/// Returns the users inventory root folder.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="user">The UUID of the user who is having inventory being returned</param>
|
|
||||||
/// <returns>Root inventory folder</returns>
|
|
||||||
public InventoryFolderBase getUserRootFolder(LLUUID user)
|
public InventoryFolderBase getUserRootFolder(LLUUID user)
|
||||||
{
|
{
|
||||||
List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
|
List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
|
||||||
|
@ -242,22 +238,15 @@ namespace OpenSim.Framework.Data.SQLite
|
||||||
folders.Add(buildFolder(row));
|
folders.Add(buildFolder(row));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (folders.Count == 1)
|
// There should only ever be one root folder for a user. However, if there's more
|
||||||
|
// than one we'll simply use the first one rather than failing. It would be even
|
||||||
|
// nicer to print some message to this effect, but this feels like it's too low a
|
||||||
|
// to put such a message out, and it's too minor right now to spare the time to
|
||||||
|
// suitably refactor.
|
||||||
|
if (folders.Count > 1)
|
||||||
{
|
{
|
||||||
//we found the root
|
|
||||||
//System.Console.WriteLine("found root inventory folder");
|
|
||||||
return folders[0];
|
return folders[0];
|
||||||
}
|
}
|
||||||
else if (folders.Count > 1)
|
|
||||||
{
|
|
||||||
//err shouldn't be more than one root
|
|
||||||
//System.Console.WriteLine("found more than one root inventory folder");
|
|
||||||
}
|
|
||||||
else if (folders.Count == 0)
|
|
||||||
{
|
|
||||||
// no root?
|
|
||||||
//System.Console.WriteLine("couldn't find root inventory folder");
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,7 +184,7 @@ namespace OpenSim.Framework
|
||||||
/// Returns the users inventory root folder.
|
/// Returns the users inventory root folder.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="user">The UUID of the user who is having inventory being returned</param>
|
/// <param name="user">The UUID of the user who is having inventory being returned</param>
|
||||||
/// <returns>Root inventory folder</returns>
|
/// <returns>Root inventory folder, null if no root inventory folder was found</returns>
|
||||||
InventoryFolderBase getUserRootFolder(LLUUID user);
|
InventoryFolderBase getUserRootFolder(LLUUID user);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -197,12 +197,29 @@ namespace OpenSim.Grid.UserServer
|
||||||
|
|
||||||
protected override InventoryData CreateInventoryData(LLUUID userID)
|
protected override InventoryData CreateInventoryData(LLUUID userID)
|
||||||
{
|
{
|
||||||
List<InventoryFolderBase> folders = SynchronousRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>("POST", m_config.InventoryUrl + "RootFolders/", userID);
|
List<InventoryFolderBase> folders
|
||||||
if (folders ==null | folders.Count == 0)
|
= SynchronousRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>(
|
||||||
|
"POST", m_config.InventoryUrl + "RootFolders/", userID);
|
||||||
|
|
||||||
|
// In theory, the user will only ever be missing a root folder in situations where a grid
|
||||||
|
// which didn't previously run a grid wide inventory server is being transitioned to one
|
||||||
|
// which does.
|
||||||
|
if (null == folders | folders.Count == 0)
|
||||||
{
|
{
|
||||||
RestObjectPoster.BeginPostObject<LLUUID>(m_config.InventoryUrl + "CreateInventory/", userID);
|
MainLog.Instance.Warn(
|
||||||
Thread.Sleep(1000);
|
"LOGIN",
|
||||||
folders = SynchronousRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>("POST", m_config.InventoryUrl + "RootFolders/", userID);
|
"A root inventory folder for user ID " + userID + " was not found. A new set"
|
||||||
|
+ " of empty inventory folders is being created.");
|
||||||
|
|
||||||
|
RestObjectPoster.BeginPostObject<LLUUID>(
|
||||||
|
m_config.InventoryUrl + "CreateInventory/", userID);
|
||||||
|
|
||||||
|
// A big delay should be okay here since the recreation of the user's root folders should
|
||||||
|
// only ever happen once. We need to sleep to let the inventory server do its work -
|
||||||
|
// previously 1000ms has been found to be too short.
|
||||||
|
Thread.Sleep(10000);
|
||||||
|
folders = SynchronousRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>(
|
||||||
|
"POST", m_config.InventoryUrl + "RootFolders/", userID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (folders.Count > 0)
|
if (folders.Count > 0)
|
||||||
|
@ -228,6 +245,9 @@ namespace OpenSim.Grid.UserServer
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
MainLog.Instance.Warn("LOGIN", "The root inventory folder could still not be retrieved" +
|
||||||
|
" for user ID " + userID);
|
||||||
|
|
||||||
AgentInventory userInventory = new AgentInventory();
|
AgentInventory userInventory = new AgentInventory();
|
||||||
userInventory.CreateRootFolder(userID, false);
|
userInventory.CreateRootFolder(userID, false);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue