aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs92
-rw-r--r--OpenSim/Region/Environment/Scenes/EventManager.cs31
2 files changed, 86 insertions, 37 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
index ce293e4..ee4323c 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
@@ -53,6 +53,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
53 53
54 private Scene m_scene; 54 private Scene m_scene;
55 private Stream m_loadStream; 55 private Stream m_loadStream;
56 private string m_errorMessage;
56 57
57 /// <summary> 58 /// <summary>
58 /// Used to cache lookups for valid uuids. 59 /// Used to cache lookups for valid uuids.
@@ -63,6 +64,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
63 { 64 {
64 m_scene = scene; 65 m_scene = scene;
65 m_loadStream = new GZipStream(GetStream(loadPath), CompressionMode.Decompress); 66 m_loadStream = new GZipStream(GetStream(loadPath), CompressionMode.Decompress);
67 m_errorMessage = String.Empty;
66 } 68 }
67 69
68 public ArchiveReadRequest(Scene scene, Stream loadStream) 70 public ArchiveReadRequest(Scene scene, Stream loadStream)
@@ -82,62 +84,76 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
82 84
83 private void DearchiveRegion0DotStar() 85 private void DearchiveRegion0DotStar()
84 { 86 {
85 TarArchiveReader archive = new TarArchiveReader(m_loadStream); 87 int successfulAssetRestores = 0;
88 int failedAssetRestores = 0;
89 List<string> serialisedSceneObjects = new List<string>();
86 90
87 //AssetsDearchiver dearchiver = new AssetsDearchiver(m_scene.AssetCache); 91 try
92 {
93 TarArchiveReader archive = new TarArchiveReader(m_loadStream);
88 94
89 List<string> serialisedSceneObjects = new List<string>(); 95 //AssetsDearchiver dearchiver = new AssetsDearchiver(m_scene.AssetCache);
90 string filePath = "ERROR";
91 96
92 int successfulAssetRestores = 0; 97 string filePath = "ERROR";
93 int failedAssetRestores = 0;
94 98
95 byte[] data; 99 byte[] data;
96 TarArchiveReader.TarEntryType entryType; 100 TarArchiveReader.TarEntryType entryType;
97 101
98 while ((data = archive.ReadEntry(out filePath, out entryType)) != null) 102 while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
99 {
100 //m_log.DebugFormat(
101 // "[ARCHIVER]: Successfully read {0} ({1} bytes)}", filePath, data.Length);
102 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType)
103 { 103 {
104 m_log.WarnFormat("[ARCHIVER]: Ignoring directory entry {0}", 104 //m_log.DebugFormat(
105 filePath); 105 // "[ARCHIVER]: Successfully read {0} ({1} bytes)}", filePath, data.Length);
106 } 106 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType)
107 else if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH)) 107 {
108 { 108 m_log.WarnFormat("[ARCHIVER]: Ignoring directory entry {0}",
109 serialisedSceneObjects.Add(m_asciiEncoding.GetString(data)); 109 filePath);
110 } 110 }
111 else if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH))
112 {
113 serialisedSceneObjects.Add(m_asciiEncoding.GetString(data));
114 }
111// else if (filePath.Equals(ArchiveConstants.ASSETS_METADATA_PATH)) 115// else if (filePath.Equals(ArchiveConstants.ASSETS_METADATA_PATH))
112// { 116// {
113// string xml = m_asciiEncoding.GetString(data); 117// string xml = m_asciiEncoding.GetString(data);
114// dearchiver.AddAssetMetadata(xml); 118// dearchiver.AddAssetMetadata(xml);
115// } 119// }
116 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) 120 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
117 { 121 {
118 if (LoadAsset(filePath, data)) 122 if (LoadAsset(filePath, data))
119 successfulAssetRestores++; 123 successfulAssetRestores++;
120 else 124 else
121 failedAssetRestores++; 125 failedAssetRestores++;
122 } 126 }
123 else if (filePath.StartsWith(ArchiveConstants.TERRAINS_PATH)) 127 else if (filePath.StartsWith(ArchiveConstants.TERRAINS_PATH))
124 { 128 {
125 LoadTerrain(filePath, data); 129 LoadTerrain(filePath, data);
126 } 130 }
127 else if (filePath.StartsWith(ArchiveConstants.SETTINGS_PATH)) 131 else if (filePath.StartsWith(ArchiveConstants.SETTINGS_PATH))
128 { 132 {
129 LoadRegionSettings(filePath, data); 133 LoadRegionSettings(filePath, data);
134 }
130 } 135 }
131 }
132 136
133 //m_log.Debug("[ARCHIVER]: Reached end of archive"); 137 //m_log.Debug("[ARCHIVER]: Reached end of archive");
134 138
135 archive.Close(); 139 archive.Close();
140 }
141 catch (Exception e)
142 {
143 m_log.ErrorFormat(
144 "[ARCHIVER]: Error loading oar file. Exception was: {0}", e);
145 m_errorMessage += e.ToString();
146 m_scene.EventManager.TriggerOarFileLoaded(m_errorMessage);
147 return;
148 }
136 149
137 m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores); 150 m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores);
138 151
139 if (failedAssetRestores > 0) 152 if (failedAssetRestores > 0)
153 {
140 m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores); 154 m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores);
155 m_errorMessage += String.Format("Failed to load {0} assets", failedAssetRestores);
156 }
141 157
142 m_log.Info("[ARCHIVER]: Clearing all existing scene objects"); 158 m_log.Info("[ARCHIVER]: Clearing all existing scene objects");
143 m_scene.DeleteAllSceneObjects(); 159 m_scene.DeleteAllSceneObjects();
@@ -217,6 +233,8 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
217 { 233 {
218 sceneObject.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 0); 234 sceneObject.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 0);
219 } 235 }
236 m_scene.EventManager.TriggerOarFileLoaded(m_errorMessage);
237
220 } 238 }
221 239
222 /// <summary> 240 /// <summary>
diff --git a/OpenSim/Region/Environment/Scenes/EventManager.cs b/OpenSim/Region/Environment/Scenes/EventManager.cs
index b493f84..1543bf0 100644
--- a/OpenSim/Region/Environment/Scenes/EventManager.cs
+++ b/OpenSim/Region/Environment/Scenes/EventManager.cs
@@ -266,6 +266,21 @@ namespace OpenSim.Region.Environment.Scenes
266 public delegate float SunLindenHour(); 266 public delegate float SunLindenHour();
267 public event SunLindenHour OnGetSunLindenHour; 267 public event SunLindenHour OnGetSunLindenHour;
268 268
269 /// <summary>
270 /// Called when oar file has finished loading, although
271 /// the scripts may not have started yet
272 /// Message is non empty string if there were problems loading the oar file
273 /// </summary>
274 public delegate void OarFileLoaded(string message);
275 public event OarFileLoaded OnOarFileLoaded;
276
277 /// <summary>
278 /// Called when the script compile queue becomes empty
279 /// Returns the number of scripts which failed to start
280 /// </summary>
281 public delegate void EmptyScriptCompileQueue(int numScriptsFailed, string message);
282 public event EmptyScriptCompileQueue OnEmptyScriptCompileQueue;
283
269 public class MoneyTransferArgs : EventArgs 284 public class MoneyTransferArgs : EventArgs
270 { 285 {
271 public UUID sender; 286 public UUID sender;
@@ -399,6 +414,8 @@ namespace OpenSim.Region.Environment.Scenes
399 private SunLindenHour handlerSunGetLindenHour = null; 414 private SunLindenHour handlerSunGetLindenHour = null;
400 private OnSetRootAgentSceneDelegate handlerSetRootAgentScene = null; 415 private OnSetRootAgentSceneDelegate handlerSetRootAgentScene = null;
401 416
417 private OarFileLoaded handlerOarFileLoaded = null;
418 private EmptyScriptCompileQueue handlerEmptyScriptCompileQueue = null;
402 419
403 public void TriggerGetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) 420 public void TriggerGetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
404 { 421 {
@@ -902,6 +919,20 @@ namespace OpenSim.Region.Environment.Scenes
902 return 6; 919 return 6;
903 } 920 }
904 921
922 public void TriggerOarFileLoaded(string message)
923 {
924 handlerOarFileLoaded = OnOarFileLoaded;
925 if (handlerOarFileLoaded != null)
926 handlerOarFileLoaded(message);
927 }
928
929 public void TriggerEmptyScriptCompileQueue(int numScriptsFailed, string message)
930 {
931 handlerEmptyScriptCompileQueue = OnEmptyScriptCompileQueue;
932 if (handlerEmptyScriptCompileQueue != null)
933 handlerEmptyScriptCompileQueue(numScriptsFailed, message);
934 }
935
905 public void TriggerScriptCollidingStart(uint localId, ColliderArgs colliders) 936 public void TriggerScriptCollidingStart(uint localId, ColliderArgs colliders)
906 { 937 {
907 handlerCollidingStart = OnScriptColliderStart; 938 handlerCollidingStart = OnScriptColliderStart;