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
|
@ -104,13 +104,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||||
List<string> serialisedParcels = new List<string>();
|
List<string> serialisedParcels = new List<string>();
|
||||||
string filePath = "NONE";
|
string filePath = "NONE";
|
||||||
|
|
||||||
|
TarArchiveReader archive = new TarArchiveReader(m_loadStream);
|
||||||
|
byte[] data;
|
||||||
|
TarArchiveReader.TarEntryType entryType;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
TarArchiveReader archive = new TarArchiveReader(m_loadStream);
|
|
||||||
|
|
||||||
byte[] data;
|
|
||||||
TarArchiveReader.TarEntryType entryType;
|
|
||||||
|
|
||||||
while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
|
while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
|
||||||
{
|
{
|
||||||
//m_log.DebugFormat(
|
//m_log.DebugFormat(
|
||||||
|
@ -152,8 +151,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||||
}
|
}
|
||||||
|
|
||||||
//m_log.Debug("[ARCHIVER]: Reached end of archive");
|
//m_log.Debug("[ARCHIVER]: Reached end of archive");
|
||||||
|
|
||||||
archive.Close();
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -163,6 +160,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||||
m_scene.EventManager.TriggerOarFileLoaded(m_requestId, m_errorMessage);
|
m_scene.EventManager.TriggerOarFileLoaded(m_requestId, m_errorMessage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
archive.Close();
|
||||||
|
}
|
||||||
|
|
||||||
m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores);
|
m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores);
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,22 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||||
|
|
||||||
protected internal void ReceivedAllAssets(
|
protected internal void ReceivedAllAssets(
|
||||||
ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids)
|
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)
|
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_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>
|
/// <summary>
|
||||||
|
|
|
@ -56,6 +56,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// </summary>
|
/// </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)
|
public ArchiveWriteRequestPreparation(Scene scene, string savePath, Guid requestId)
|
||||||
{
|
{
|
||||||
m_scene = scene;
|
m_scene = scene;
|
||||||
|
|
Loading…
Reference in New Issue