aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-04-28 19:40:02 +0000
committerJustin Clarke Casey2009-04-28 19:40:02 +0000
commit898326b5e9e3f4fe509a1e880dbdc58d6c1b9ecb (patch)
tree18f03a1c7eb655f3a30e902e824d4b48d44bb318
parent* Add preliminary code for resolving iar profile names (diff)
downloadopensim-SC_OLD-898326b5e9e3f4fe509a1e880dbdc58d6c1b9ecb.zip
opensim-SC_OLD-898326b5e9e3f4fe509a1e880dbdc58d6c1b9ecb.tar.gz
opensim-SC_OLD-898326b5e9e3f4fe509a1e880dbdc58d6c1b9ecb.tar.bz2
opensim-SC_OLD-898326b5e9e3f4fe509a1e880dbdc58d6c1b9ecb.tar.xz
* Stop oar loading barfing if the archive contains directory entries
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs18
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs38
2 files changed, 44 insertions, 12 deletions
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
99 int successfulAssetRestores = 0; 99 int successfulAssetRestores = 0;
100 int failedAssetRestores = 0; 100 int failedAssetRestores = 0;
101 List<string> serialisedSceneObjects = new List<string>(); 101 List<string> serialisedSceneObjects = new List<string>();
102 102 string filePath = "NONE";
103
103 try 104 try
104 { 105 {
105 TarArchiveReader archive = new TarArchiveReader(m_loadStream); 106 TarArchiveReader archive = new TarArchiveReader(m_loadStream);
106 107
107 string filePath = "ERROR";
108
109 byte[] data; 108 byte[] data;
110 TarArchiveReader.TarEntryType entryType; 109 TarArchiveReader.TarEntryType entryType;
111 110
112 while ((data = archive.ReadEntry(out filePath, out entryType)) != null) 111 while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
113 { 112 {
114 //m_log.DebugFormat( 113 m_log.DebugFormat(
115 // "[ARCHIVER]: Successfully read {0} ({1} bytes)}", filePath, data.Length); 114 "[ARCHIVER]: Successfully read {0} ({1} bytes)", filePath, data.Length);
115
116 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType)
117 continue;
116 118
117 if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH)) 119 if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH))
118 { 120 {
@@ -142,7 +144,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
142 catch (Exception e) 144 catch (Exception e)
143 { 145 {
144 m_log.ErrorFormat( 146 m_log.ErrorFormat(
145 "[ARCHIVER]: Error loading oar file. Exception was: {0}", e); 147 "[ARCHIVER]: Aborting load with error in archive file {0}. {1}", filePath, e);
146 m_errorMessage += e.ToString(); 148 m_errorMessage += e.ToString();
147 m_scene.EventManager.TriggerOarFileLoaded(m_requestId, m_errorMessage); 149 m_scene.EventManager.TriggerOarFileLoaded(m_requestId, m_errorMessage);
148 return; 150 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
48 public class ArchiverTests 48 public class ArchiverTests
49 { 49 {
50 private Guid m_lastRequestId; 50 private Guid m_lastRequestId;
51 private string m_lastErrorMessage;
52
53 private void LoadCompleted(Guid requestId, string errorMessage)
54 {
55 lock (this)
56 {
57 m_lastRequestId = requestId;
58 m_lastErrorMessage = errorMessage;
59 Console.WriteLine("About to pulse ArchiverTests on LoadCompleted");
60
61 Monitor.PulseAll(this);
62 }
63 }
51 64
52 private void SaveCompleted(Guid requestId, string errorMessage) 65 private void SaveCompleted(Guid requestId, string errorMessage)
53 { 66 {
54 lock (this) 67 lock (this)
55 { 68 {
56 m_lastRequestId = requestId; 69 m_lastRequestId = requestId;
57 System.Console.WriteLine("About to pulse ArchiverTests"); 70 m_lastErrorMessage = errorMessage;
71 Console.WriteLine("About to pulse ArchiverTests on SaveCompleted");
58 Monitor.PulseAll(this); 72 Monitor.PulseAll(this);
59 } 73 }
60 } 74 }
@@ -188,10 +202,17 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
188 [Test] 202 [Test]
189 public void TestLoadOarV0p2() 203 public void TestLoadOarV0p2()
190 { 204 {
191 //log4net.Config.XmlConfigurator.Configure(); 205 log4net.Config.XmlConfigurator.Configure();
192 206
193 MemoryStream archiveWriteStream = new MemoryStream(); 207 MemoryStream archiveWriteStream = new MemoryStream();
194 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); 208 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
209
210 // Put in a random blank directory to check that this doesn't upset the load process
211 tar.WriteDir("ignoreme");
212
213 // Also check that direct entries which will also have a file entry containing that directory doesn't
214 // upset load
215 tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
195 216
196 tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile()); 217 tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile());
197 218
@@ -220,12 +241,21 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
220 Math.Round(groupPosition.X), Math.Round(groupPosition.Y), Math.Round(groupPosition.Z), 241 Math.Round(groupPosition.X), Math.Round(groupPosition.Y), Math.Round(groupPosition.Z),
221 part1.UUID); 242 part1.UUID);
222 tar.WriteFile(ArchiveConstants.OBJECTS_PATH + object1FileName, object1.ToXmlString2()); 243 tar.WriteFile(ArchiveConstants.OBJECTS_PATH + object1FileName, object1.ToXmlString2());
223 244
224 tar.Close(); 245 tar.Close();
225 246
226 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); 247 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
227 248
228 archiverModule.DearchiveRegion(archiveReadStream); 249 lock (this)
250 {
251 scene.EventManager.OnOarFileLoaded += LoadCompleted;
252 archiverModule.DearchiveRegion(archiveReadStream);
253
254 // Load occurs asynchronously right now
255 //Monitor.Wait(this, 60000);
256 }
257
258 Assert.That(m_lastErrorMessage, Is.Null);
229 259
230 SceneObjectPart object1PartLoaded = scene.GetSceneObjectPart(part1Name); 260 SceneObjectPart object1PartLoaded = scene.GetSceneObjectPart(part1Name);
231 261