* When an inventory archive is loaded, immediately update the client's inventory if that client is online at that region server

* Not useable yet
0.6.3-post-fixes
Justin Clarke Casey 2009-02-11 20:24:41 +00:00
parent 8645c7482d
commit 9b6035c2a6
2 changed files with 62 additions and 21 deletions

View File

@ -161,18 +161,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
return item;
}
public void Execute()
/// <summary>
/// Execute the request
/// </summary>
/// <returns>
/// A list of the inventory nodes loaded. If folders were loaded then only the root folders are
/// returned
/// </returns>
public List<InventoryNodeBase> Execute()
{
string filePath = "ERROR";
int successfulAssetRestores = 0;
int failedAssetRestores = 0;
int successfulItemRestores = 0;
List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>();
UserProfileData userProfile = commsManager.UserService.GetUserProfile(m_firstName, m_lastName);
if (null == userProfile)
{
m_log.ErrorFormat("[INVENTORY ARCHIVER]: Failed to find user {0} {1}", m_firstName, m_lastName);
return;
return nodesLoaded;
}
CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userProfile.ID);
@ -182,7 +190,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
"[INVENTORY ARCHIVER]: Failed to find user info for {0} {1} {2}",
m_firstName, m_lastName, userProfile.ID);
return;
return nodesLoaded;
}
if (!userInfo.HasReceivedInventory)
@ -191,7 +199,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
"[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1} {2}",
m_firstName, m_lastName, userProfile.ID);
return;
return nodesLoaded;
}
InventoryFolderImpl inventoryFolder = userInfo.RootFolder.FindFolderByPath(m_invPath);
@ -201,7 +209,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
// TODO: Later on, automatically create this folder if it does not exist
m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath);
return;
return nodesLoaded;
}
archive = new TarArchiveReader(m_loadStream);
@ -236,6 +244,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
userInfo.AddItem(item);
successfulItemRestores++;
nodesLoaded.Add(item);
}
}
}
@ -244,6 +253,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
m_log.DebugFormat("[INVENTORY ARCHIVER]: Restored {0} assets", successfulAssetRestores);
m_log.InfoFormat("[INVENTORY ARCHIVER]: Restored {0} items", successfulItemRestores);
return nodesLoaded;
}
/// <summary>

View File

@ -31,6 +31,7 @@ using System.Reflection;
using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
@ -96,7 +97,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
{
if (m_scenes.Count > 0)
{
new InventoryArchiveReadRequest(firstName, lastName, invPath, loadStream, m_commsManager).Execute();
InventoryArchiveReadRequest request =
new InventoryArchiveReadRequest(firstName, lastName, invPath, loadStream, m_commsManager);
UpdateClientWithLoadedNodes(firstName, lastName, request.Execute());
}
}
@ -111,20 +115,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
public void DearchiveInventory(string firstName, string lastName, string invPath, string loadPath)
{
if (m_scenes.Count > 0)
{
new InventoryArchiveReadRequest(firstName, lastName, invPath, loadPath, m_commsManager).Execute();
}
/*
foreach (Scene scene in m_scenes.Values)
{
ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID));
if (user != null && !user.IsChildAgent)
{
user.ControllingClient.SendBulkUpdateInventory(folderCopy);
}
}
*/
{
InventoryArchiveReadRequest request =
new InventoryArchiveReadRequest(firstName, lastName, invPath, loadPath, m_commsManager);
UpdateClientWithLoadedNodes(firstName, lastName, request.Execute());
}
}
public void ArchiveInventory(string firstName, string lastName, string invPath, string savePath)
@ -175,6 +171,40 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
string savePath = (cmdparams.Length > 5 ? cmdparams[5] : DEFAULT_INV_BACKUP_FILENAME);
ArchiveInventory(firstName, lastName, invPath, savePath);
}
}
/// <summary>
/// Notify the client of loaded nodes if they are logged in
/// </summary>
/// <param name="loadedNodes">Can be empty. In which case, nothing happens</param>
private void UpdateClientWithLoadedNodes(string firstName, string lastName, List<InventoryNodeBase> loadedNodes)
{
if (loadedNodes.Count == 0)
return;
UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(firstName, lastName);
if (null == userProfile)
return;
foreach (Scene scene in m_scenes.Values)
{
ScenePresence user = scene.GetScenePresence(userProfile.ID);
if (user != null && !user.IsChildAgent)
{
foreach (InventoryNodeBase node in loadedNodes)
{
m_log.DebugFormat(
"[INVENTORY ARCHIVER]: Notifying {0} of loaded inventory node {1}",
user.Name, node.Name);
user.ControllingClient.SendBulkUpdateInventory(node);
}
break;
}
}
}
}
}