* 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) catch (IOException e)
{ {
m_saveStream.Close();
reportedException = e; reportedException = e;
succeeded = false; succeeded = false;
} }
@ -104,9 +105,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
protected void saveInvItem(InventoryItemBase inventoryItem, string path) protected void saveInvItem(InventoryItemBase inventoryItem, string path)
{ {
string filename string filename = string.Format("{0}{1}_{2}.xml", path, inventoryItem.Name, inventoryItem.ID);
= string.Format("{0}{1}_{2}.xml",
path, inventoryItem.Name, inventoryItem.ID);
StringWriter sw = new StringWriter(); StringWriter sw = new StringWriter();
XmlTextWriter writer = new XmlTextWriter(sw); XmlTextWriter writer = new XmlTextWriter(sw);
writer.Formatting = Formatting.Indented; writer.Formatting = Formatting.Indented;
@ -182,6 +181,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
List<InventoryItemBase> items = inventoryFolder.RequestListOfItems(); List<InventoryItemBase> items = inventoryFolder.RequestListOfItems();
string newPath = path + inventoryFolder.Name + InventoryFolderImpl.PATH_DELIMITER; string newPath = path + inventoryFolder.Name + InventoryFolderImpl.PATH_DELIMITER;
archive.AddDir(newPath); archive.AddDir(newPath);
foreach (InventoryFolderImpl folder in inventories) foreach (InventoryFolderImpl folder in inventories)
{ {
saveInvDir(folder, newPath); saveInvDir(folder, newPath);
@ -192,6 +192,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
} }
} }
/// <summary>
/// Execute the inventory write request
/// </summary>
public void Execute() public void Execute()
{ {
InventoryFolderImpl inventoryFolder = null; InventoryFolderImpl inventoryFolder = null;
@ -251,7 +254,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
{ {
if (null == inventoryItem) 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; return;
} }
else else

View File

@ -73,7 +73,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
if (m_scenes.Count == 0) if (m_scenes.Count == 0)
{ {
scene.RegisterModuleInterface<IInventoryArchiverModule>(this); scene.RegisterModuleInterface<IInventoryArchiverModule>(this);
CommsManager = scene.CommsManager; CommsManager = scene.CommsManager;
OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted;
scene.AddCommand( scene.AddCommand(
this, "load iar", this, "load iar",
@ -207,11 +208,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
"[INVENTORY ARCHIVER]: Saving archive {0} from inventory path {1} for {2} {3}", "[INVENTORY ARCHIVER]: Saving archive {0} from inventory path {1} for {2} {3}",
savePath, invPath, firstName, lastName); savePath, invPath, firstName, lastName);
ArchiveInventory(firstName, lastName, invPath, savePath); ArchiveInventory(firstName, lastName, invPath, savePath);
}
m_log.InfoFormat(
"[INVENTORY ARCHIVER]: Saved archive {0} for {1} {2}", private void SaveInvConsoleCommandCompleted(
savePath, firstName, lastName); 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> /// <summary>