* Stop oar loading barfing if the archive contains directory entries

0.6.5-rc1
Justin Clarke Casey 2009-04-28 19:40:02 +00:00
parent 52d5628806
commit 898326b5e9
2 changed files with 44 additions and 12 deletions

View File

@ -99,20 +99,22 @@ namespace OpenSim.Region.CoreModules.World.Archiver
int successfulAssetRestores = 0;
int failedAssetRestores = 0;
List<string> serialisedSceneObjects = new List<string>();
string filePath = "NONE";
try
{
TarArchiveReader archive = new TarArchiveReader(m_loadStream);
string filePath = "ERROR";
byte[] data;
TarArchiveReader.TarEntryType entryType;
while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
{
//m_log.DebugFormat(
// "[ARCHIVER]: Successfully read {0} ({1} bytes)}", filePath, data.Length);
{
m_log.DebugFormat(
"[ARCHIVER]: Successfully read {0} ({1} bytes)", filePath, data.Length);
if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType)
continue;
if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH))
{
@ -142,7 +144,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
catch (Exception e)
{
m_log.ErrorFormat(
"[ARCHIVER]: Error loading oar file. Exception was: {0}", e);
"[ARCHIVER]: Aborting load with error in archive file {0}. {1}", filePath, e);
m_errorMessage += e.ToString();
m_scene.EventManager.TriggerOarFileLoaded(m_requestId, m_errorMessage);
return;

View File

@ -48,13 +48,27 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
public class ArchiverTests
{
private Guid m_lastRequestId;
private string m_lastErrorMessage;
private void LoadCompleted(Guid requestId, string errorMessage)
{
lock (this)
{
m_lastRequestId = requestId;
m_lastErrorMessage = errorMessage;
Console.WriteLine("About to pulse ArchiverTests on LoadCompleted");
Monitor.PulseAll(this);
}
}
private void SaveCompleted(Guid requestId, string errorMessage)
{
lock (this)
{
m_lastRequestId = requestId;
System.Console.WriteLine("About to pulse ArchiverTests");
m_lastErrorMessage = errorMessage;
Console.WriteLine("About to pulse ArchiverTests on SaveCompleted");
Monitor.PulseAll(this);
}
}
@ -188,10 +202,17 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
[Test]
public void TestLoadOarV0p2()
{
//log4net.Config.XmlConfigurator.Configure();
log4net.Config.XmlConfigurator.Configure();
MemoryStream archiveWriteStream = new MemoryStream();
TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
// Put in a random blank directory to check that this doesn't upset the load process
tar.WriteDir("ignoreme");
// Also check that direct entries which will also have a file entry containing that directory doesn't
// upset load
tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile());
@ -220,12 +241,21 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
Math.Round(groupPosition.X), Math.Round(groupPosition.Y), Math.Round(groupPosition.Z),
part1.UUID);
tar.WriteFile(ArchiveConstants.OBJECTS_PATH + object1FileName, object1.ToXmlString2());
tar.Close();
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
archiverModule.DearchiveRegion(archiveReadStream);
lock (this)
{
scene.EventManager.OnOarFileLoaded += LoadCompleted;
archiverModule.DearchiveRegion(archiveReadStream);
// Load occurs asynchronously right now
//Monitor.Wait(this, 60000);
}
Assert.That(m_lastErrorMessage, Is.Null);
SceneObjectPart object1PartLoaded = scene.GetSceneObjectPart(part1Name);