make save and load oar slightly more robust by always closing the archive streams even if there has been an error
parent
73dcbbd57a
commit
c083ab6824
|
@ -103,14 +103,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
List<string> serialisedSceneObjects = new List<string>();
|
||||
List<string> serialisedParcels = new List<string>();
|
||||
string filePath = "NONE";
|
||||
|
||||
TarArchiveReader archive = new TarArchiveReader(m_loadStream);
|
||||
byte[] data;
|
||||
TarArchiveReader.TarEntryType entryType;
|
||||
|
||||
try
|
||||
{
|
||||
TarArchiveReader archive = new TarArchiveReader(m_loadStream);
|
||||
|
||||
byte[] data;
|
||||
TarArchiveReader.TarEntryType entryType;
|
||||
|
||||
while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
|
||||
{
|
||||
//m_log.DebugFormat(
|
||||
|
@ -152,8 +151,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
}
|
||||
|
||||
//m_log.Debug("[ARCHIVER]: Reached end of archive");
|
||||
|
||||
archive.Close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -163,6 +160,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
m_scene.EventManager.TriggerOarFileLoaded(m_requestId, m_errorMessage);
|
||||
return;
|
||||
}
|
||||
finally
|
||||
{
|
||||
archive.Close();
|
||||
}
|
||||
|
||||
m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores);
|
||||
|
||||
|
|
|
@ -79,6 +79,22 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
|
||||
protected internal void ReceivedAllAssets(
|
||||
ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids)
|
||||
{
|
||||
try
|
||||
{
|
||||
Save(assetsFoundUuids, assetsNotFoundUuids);
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_archiveWriter.Close();
|
||||
}
|
||||
|
||||
m_log.InfoFormat("[ARCHIVER]: Finished writing out OAR for {0}", m_scene.RegionInfo.RegionName);
|
||||
|
||||
m_scene.EventManager.TriggerOarFileSaved(m_requestId, String.Empty);
|
||||
}
|
||||
|
||||
protected internal void Save(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids)
|
||||
{
|
||||
foreach (UUID uuid in assetsNotFoundUuids)
|
||||
{
|
||||
|
@ -143,12 +159,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
}
|
||||
|
||||
m_log.InfoFormat("[ARCHIVER]: Added scene objects to archive.");
|
||||
|
||||
m_archiveWriter.Close();
|
||||
|
||||
m_log.InfoFormat("[ARCHIVER]: Finished writing out OAR for {0}", m_scene.RegionInfo.RegionName);
|
||||
|
||||
m_scene.EventManager.TriggerOarFileSaved(m_requestId, String.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -56,6 +56,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="scene"></param>
|
||||
/// <param name="savePath">The path to which to save data.</param>
|
||||
/// <param name="requestId">The id associated with this request</param>
|
||||
/// <exception cref="System.IO.IOException">
|
||||
/// If there was a problem opening a stream for the file specified by the savePath
|
||||
/// </exception>
|
||||
public ArchiveWriteRequestPreparation(Scene scene, string savePath, Guid requestId)
|
||||
{
|
||||
m_scene = scene;
|
||||
|
|
Loading…
Reference in New Issue