* Stop oar loading barfing if the archive contains directory entries
parent
52d5628806
commit
898326b5e9
|
@ -99,20 +99,22 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||||
int successfulAssetRestores = 0;
|
int successfulAssetRestores = 0;
|
||||||
int failedAssetRestores = 0;
|
int failedAssetRestores = 0;
|
||||||
List<string> serialisedSceneObjects = new List<string>();
|
List<string> serialisedSceneObjects = new List<string>();
|
||||||
|
string filePath = "NONE";
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
TarArchiveReader archive = new TarArchiveReader(m_loadStream);
|
TarArchiveReader archive = new TarArchiveReader(m_loadStream);
|
||||||
|
|
||||||
string filePath = "ERROR";
|
|
||||||
|
|
||||||
byte[] data;
|
byte[] data;
|
||||||
TarArchiveReader.TarEntryType entryType;
|
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(
|
||||||
// "[ARCHIVER]: Successfully read {0} ({1} bytes)}", filePath, data.Length);
|
"[ARCHIVER]: Successfully read {0} ({1} bytes)", filePath, data.Length);
|
||||||
|
|
||||||
|
if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH))
|
if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH))
|
||||||
{
|
{
|
||||||
|
@ -142,7 +144,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
m_log.ErrorFormat(
|
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_errorMessage += e.ToString();
|
||||||
m_scene.EventManager.TriggerOarFileLoaded(m_requestId, m_errorMessage);
|
m_scene.EventManager.TriggerOarFileLoaded(m_requestId, m_errorMessage);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -48,13 +48,27 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
|
||||||
public class ArchiverTests
|
public class ArchiverTests
|
||||||
{
|
{
|
||||||
private Guid m_lastRequestId;
|
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)
|
private void SaveCompleted(Guid requestId, string errorMessage)
|
||||||
{
|
{
|
||||||
lock (this)
|
lock (this)
|
||||||
{
|
{
|
||||||
m_lastRequestId = requestId;
|
m_lastRequestId = requestId;
|
||||||
System.Console.WriteLine("About to pulse ArchiverTests");
|
m_lastErrorMessage = errorMessage;
|
||||||
|
Console.WriteLine("About to pulse ArchiverTests on SaveCompleted");
|
||||||
Monitor.PulseAll(this);
|
Monitor.PulseAll(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,10 +202,17 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
|
||||||
[Test]
|
[Test]
|
||||||
public void TestLoadOarV0p2()
|
public void TestLoadOarV0p2()
|
||||||
{
|
{
|
||||||
//log4net.Config.XmlConfigurator.Configure();
|
log4net.Config.XmlConfigurator.Configure();
|
||||||
|
|
||||||
MemoryStream archiveWriteStream = new MemoryStream();
|
MemoryStream archiveWriteStream = new MemoryStream();
|
||||||
TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
|
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());
|
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),
|
Math.Round(groupPosition.X), Math.Round(groupPosition.Y), Math.Round(groupPosition.Z),
|
||||||
part1.UUID);
|
part1.UUID);
|
||||||
tar.WriteFile(ArchiveConstants.OBJECTS_PATH + object1FileName, object1.ToXmlString2());
|
tar.WriteFile(ArchiveConstants.OBJECTS_PATH + object1FileName, object1.ToXmlString2());
|
||||||
|
|
||||||
tar.Close();
|
tar.Close();
|
||||||
|
|
||||||
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
|
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);
|
SceneObjectPart object1PartLoaded = scene.GetSceneObjectPart(part1Name);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue