Make load/save iar slightly better in the face of io failures by always attempting to close the streams

0.6.8-post-fixes
Justin Clark-Casey (justincc) 2009-11-24 18:27:31 +00:00
parent c083ab6824
commit f605d59136
2 changed files with 77 additions and 63 deletions

View File

@ -121,6 +121,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
byte[] data;
TarArchiveReader.TarEntryType entryType;
try
{
while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
{
if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
@ -158,8 +161,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
}
}
}
}
finally
{
archive.Close();
}
m_log.DebugFormat(
"[INVENTORY ARCHIVER]: Successfully loaded {0} assets with {1} failures",

View File

@ -118,18 +118,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids)
{
// We're almost done. Just need to write out the control file now
m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p1ControlFile());
m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");
Exception reportedException = null;
bool succeeded = true;
try
{
// We're almost done. Just need to write out the control file now
m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p1ControlFile());
m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");
m_archiveWriter.Close();
}
catch (IOException e)
catch (Exception e)
{
m_saveStream.Close();
reportedException = e;
@ -261,8 +261,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
//inventoryItem = m_userInfo.RootFolder.FindItemByPath(m_invPath);
}
if (null == inventoryFolder && null == inventoryItem)
{
// We couldn't find the path indicated
string errorMessage = string.Format("Aborted save. Could not find inventory path {0}", m_invPath);
m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", errorMessage);
m_module.TriggerInventoryArchiveSaved(
m_id, false, m_userInfo, m_invPath, m_saveStream,
new Exception(errorMessage));
return;
}
m_archiveWriter = new TarArchiveWriter(m_saveStream);
try
{
if (inventoryFolder != null)
{
m_log.DebugFormat(
@ -280,20 +293,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH);
}
else
{
// We couldn't find the path indicated
m_saveStream.Close();
string errorMessage = string.Format("Aborted save. Could not find inventory path {0}", m_invPath);
m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", errorMessage);
m_module.TriggerInventoryArchiveSaved(
m_id, false, m_userInfo, m_invPath, m_saveStream,
new Exception(errorMessage));
return;
}
// Don't put all this profile information into the archive right now.
//SaveUsers();
}
catch (Exception)
{
m_archiveWriter.Close();
throw;
}
new AssetsRequest(
new AssetsArchiver(m_archiveWriter), m_assetUuids.Keys,