From 898326b5e9e3f4fe509a1e880dbdc58d6c1b9ecb Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 28 Apr 2009 19:40:02 +0000 Subject: * Stop oar loading barfing if the archive contains directory entries --- .../World/Archiver/ArchiveReadRequest.cs | 18 +++++----- .../World/Archiver/Tests/ArchiverTests.cs | 38 +++++++++++++++++++--- 2 files changed, 44 insertions(+), 12 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index efc4057..7f7986d 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -99,20 +99,22 @@ namespace OpenSim.Region.CoreModules.World.Archiver int successfulAssetRestores = 0; int failedAssetRestores = 0; List serialisedSceneObjects = new List(); - + 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; diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index 70ed6a7..09ff9a2 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs @@ -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); -- cgit v1.1