* Make save iar behave properly if the nominated inventory path does not exist

* load iar probably still fails for this
GenericGridServerConcept
Justin Clarke Casey 2009-02-18 19:26:10 +00:00
parent 2d7c15c560
commit 5e4cad07eb
2 changed files with 28 additions and 10 deletions

View File

@ -95,6 +95,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
}
catch (IOException e)
{
m_saveStream.Close();
reportedException = e;
succeeded = false;
}
@ -104,9 +105,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
protected void saveInvItem(InventoryItemBase inventoryItem, string path)
{
string filename
= string.Format("{0}{1}_{2}.xml",
path, inventoryItem.Name, inventoryItem.ID);
string filename = string.Format("{0}{1}_{2}.xml", path, inventoryItem.Name, inventoryItem.ID);
StringWriter sw = new StringWriter();
XmlTextWriter writer = new XmlTextWriter(sw);
writer.Formatting = Formatting.Indented;
@ -182,6 +181,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
List<InventoryItemBase> items = inventoryFolder.RequestListOfItems();
string newPath = path + inventoryFolder.Name + InventoryFolderImpl.PATH_DELIMITER;
archive.AddDir(newPath);
foreach (InventoryFolderImpl folder in inventories)
{
saveInvDir(folder, newPath);
@ -192,6 +192,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
}
}
/// <summary>
/// Execute the inventory write request
/// </summary>
public void Execute()
{
InventoryFolderImpl inventoryFolder = null;
@ -251,7 +254,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
{
if (null == inventoryItem)
{
m_log.ErrorFormat("[INVENTORY ARCHIVER]: Could not find inventory entry at path {0}", m_invPath);
m_saveStream.Close();
m_module.TriggerInventoryArchiveSaved(
false, m_userInfo, m_invPath, m_saveStream,
new Exception(string.Format("Could not find inventory entry at path {0}", m_invPath)));
return;
}
else

View File

@ -74,6 +74,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
{
scene.RegisterModuleInterface<IInventoryArchiverModule>(this);
CommsManager = scene.CommsManager;
OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted;
scene.AddCommand(
this, "load iar",
@ -208,10 +209,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
savePath, invPath, firstName, lastName);
ArchiveInventory(firstName, lastName, invPath, savePath);
}
m_log.InfoFormat(
"[INVENTORY ARCHIVER]: Saved archive {0} for {1} {2}",
savePath, firstName, lastName);
private void SaveInvConsoleCommandCompleted(
bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, Exception reportedException)
{
if (succeeded)
{
m_log.InfoFormat("[INVENTORY ARCHIVER]: Saved archive for {0}", userInfo.UserProfile.Name);
}
else
{
m_log.ErrorFormat(
"[INVENTORY ARCHIVER]: Archive save for {0} failed - {1}",
userInfo.UserProfile.Name, reportedException.Message);
}
}
/// <summary>