diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | 379 |
1 files changed, 289 insertions, 90 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 142567b..2127f4d 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | |||
@@ -43,6 +43,7 @@ using OpenSim.Region.Framework.Interfaces; | |||
43 | using OpenSim.Region.Framework.Scenes; | 43 | using OpenSim.Region.Framework.Scenes; |
44 | using OpenSim.Region.Framework.Scenes.Serialization; | 44 | using OpenSim.Region.Framework.Scenes.Serialization; |
45 | using OpenSim.Services.Interfaces; | 45 | using OpenSim.Services.Interfaces; |
46 | using System.Threading; | ||
46 | 47 | ||
47 | namespace OpenSim.Region.CoreModules.World.Archiver | 48 | namespace OpenSim.Region.CoreModules.World.Archiver |
48 | { | 49 | { |
@@ -52,7 +53,30 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
52 | public class ArchiveReadRequest | 53 | public class ArchiveReadRequest |
53 | { | 54 | { |
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 55 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
56 | |||
57 | /// <summary> | ||
58 | /// Contains data used while dearchiving a single scene. | ||
59 | /// </summary> | ||
60 | private class DearchiveContext | ||
61 | { | ||
62 | public Scene Scene { get; set; } | ||
63 | |||
64 | public List<string> SerialisedSceneObjects { get; set; } | ||
65 | |||
66 | public List<string> SerialisedParcels { get; set; } | ||
67 | |||
68 | public List<SceneObjectGroup> SceneObjects { get; set; } | ||
69 | |||
70 | public DearchiveContext(Scene scene) | ||
71 | { | ||
72 | Scene = scene; | ||
73 | SerialisedSceneObjects = new List<string>(); | ||
74 | SerialisedParcels = new List<string>(); | ||
75 | SceneObjects = new List<SceneObjectGroup>(); | ||
76 | } | ||
77 | } | ||
55 | 78 | ||
79 | |||
56 | /// <summary> | 80 | /// <summary> |
57 | /// The maximum major version of OAR that we can read. Minor versions shouldn't need a max number since version | 81 | /// The maximum major version of OAR that we can read. Minor versions shouldn't need a max number since version |
58 | /// bumps here should be compatible. | 82 | /// bumps here should be compatible. |
@@ -62,9 +86,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
62 | /// <summary> | 86 | /// <summary> |
63 | /// Has the control file been loaded for this archive? | 87 | /// Has the control file been loaded for this archive? |
64 | /// </summary> | 88 | /// </summary> |
65 | public bool ControlFileLoaded { get; private set; } | 89 | public bool ControlFileLoaded { get; private set; } |
66 | 90 | ||
67 | protected Scene m_scene; | 91 | protected string m_loadPath; |
92 | protected Scene m_rootScene; | ||
68 | protected Stream m_loadStream; | 93 | protected Stream m_loadStream; |
69 | protected Guid m_requestId; | 94 | protected Guid m_requestId; |
70 | protected string m_errorMessage; | 95 | protected string m_errorMessage; |
@@ -91,7 +116,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
91 | { | 116 | { |
92 | if (m_UserMan == null) | 117 | if (m_UserMan == null) |
93 | { | 118 | { |
94 | m_UserMan = m_scene.RequestModuleInterface<IUserManagement>(); | 119 | m_UserMan = m_rootScene.RequestModuleInterface<IUserManagement>(); |
95 | } | 120 | } |
96 | return m_UserMan; | 121 | return m_UserMan; |
97 | } | 122 | } |
@@ -104,10 +129,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
104 | 129 | ||
105 | private IGroupsModule m_groupsModule; | 130 | private IGroupsModule m_groupsModule; |
106 | 131 | ||
132 | private IAssetService m_assetService = null; | ||
133 | |||
134 | |||
107 | public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, Guid requestId) | 135 | public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, Guid requestId) |
108 | { | 136 | { |
109 | m_scene = scene; | 137 | m_rootScene = scene; |
110 | 138 | ||
139 | m_loadPath = loadPath; | ||
111 | try | 140 | try |
112 | { | 141 | { |
113 | m_loadStream = new GZipStream(ArchiveHelpers.GetStream(loadPath), CompressionMode.Decompress); | 142 | m_loadStream = new GZipStream(ArchiveHelpers.GetStream(loadPath), CompressionMode.Decompress); |
@@ -128,12 +157,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
128 | // Zero can never be a valid user id | 157 | // Zero can never be a valid user id |
129 | m_validUserUuids[UUID.Zero] = false; | 158 | m_validUserUuids[UUID.Zero] = false; |
130 | 159 | ||
131 | m_groupsModule = m_scene.RequestModuleInterface<IGroupsModule>(); | 160 | m_groupsModule = m_rootScene.RequestModuleInterface<IGroupsModule>(); |
161 | m_assetService = m_rootScene.AssetService; | ||
132 | } | 162 | } |
133 | 163 | ||
134 | public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, bool skipAssets, Guid requestId) | 164 | public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, bool skipAssets, Guid requestId) |
135 | { | 165 | { |
136 | m_scene = scene; | 166 | m_rootScene = scene; |
167 | m_loadPath = null; | ||
137 | m_loadStream = loadStream; | 168 | m_loadStream = loadStream; |
138 | m_merge = merge; | 169 | m_merge = merge; |
139 | m_skipAssets = skipAssets; | 170 | m_skipAssets = skipAssets; |
@@ -142,7 +173,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
142 | // Zero can never be a valid user id | 173 | // Zero can never be a valid user id |
143 | m_validUserUuids[UUID.Zero] = false; | 174 | m_validUserUuids[UUID.Zero] = false; |
144 | 175 | ||
145 | m_groupsModule = m_scene.RequestModuleInterface<IGroupsModule>(); | 176 | m_groupsModule = m_rootScene.RequestModuleInterface<IGroupsModule>(); |
177 | m_assetService = m_rootScene.AssetService; | ||
146 | } | 178 | } |
147 | 179 | ||
148 | /// <summary> | 180 | /// <summary> |
@@ -150,25 +182,25 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
150 | /// </summary> | 182 | /// </summary> |
151 | public void DearchiveRegion() | 183 | public void DearchiveRegion() |
152 | { | 184 | { |
153 | // The same code can handle dearchiving 0.1 and 0.2 OpenSim Archive versions | ||
154 | DearchiveRegion0DotStar(); | ||
155 | } | ||
156 | |||
157 | private void DearchiveRegion0DotStar() | ||
158 | { | ||
159 | int successfulAssetRestores = 0; | 185 | int successfulAssetRestores = 0; |
160 | int failedAssetRestores = 0; | 186 | int failedAssetRestores = 0; |
161 | List<string> serialisedSceneObjects = new List<string>(); | ||
162 | List<string> serialisedParcels = new List<string>(); | ||
163 | string filePath = "NONE"; | ||
164 | 187 | ||
165 | TarArchiveReader archive = new TarArchiveReader(m_loadStream); | 188 | DearchiveScenesInfo dearchivedScenes; |
189 | |||
190 | // We dearchive all the scenes at once, because the files in the TAR archive might be mixed. | ||
191 | // Therefore, we have to keep track of the dearchive context of all the scenes. | ||
192 | Dictionary<UUID, DearchiveContext> sceneContexts = new Dictionary<UUID, DearchiveContext>(); | ||
193 | |||
194 | string fullPath = "NONE"; | ||
195 | TarArchiveReader archive = null; | ||
166 | byte[] data; | 196 | byte[] data; |
167 | TarArchiveReader.TarEntryType entryType; | 197 | TarArchiveReader.TarEntryType entryType; |
168 | 198 | ||
169 | try | 199 | try |
170 | { | 200 | { |
171 | while ((data = archive.ReadEntry(out filePath, out entryType)) != null) | 201 | FindAndLoadControlFile(out archive, out dearchivedScenes); |
202 | |||
203 | while ((data = archive.ReadEntry(out fullPath, out entryType)) != null) | ||
172 | { | 204 | { |
173 | //m_log.DebugFormat( | 205 | //m_log.DebugFormat( |
174 | // "[ARCHIVER]: Successfully read {0} ({1} bytes)", filePath, data.Length); | 206 | // "[ARCHIVER]: Successfully read {0} ({1} bytes)", filePath, data.Length); |
@@ -176,9 +208,30 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
176 | if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType) | 208 | if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType) |
177 | continue; | 209 | continue; |
178 | 210 | ||
211 | |||
212 | // Find the scene that this file belongs to | ||
213 | |||
214 | Scene scene; | ||
215 | string filePath; | ||
216 | if (!dearchivedScenes.GetRegionFromPath(fullPath, out scene, out filePath)) | ||
217 | continue; // this file belongs to a region that we're not loading | ||
218 | |||
219 | DearchiveContext sceneContext = null; | ||
220 | if (scene != null) | ||
221 | { | ||
222 | if (!sceneContexts.TryGetValue(scene.RegionInfo.RegionID, out sceneContext)) | ||
223 | { | ||
224 | sceneContext = new DearchiveContext(scene); | ||
225 | sceneContexts.Add(scene.RegionInfo.RegionID, sceneContext); | ||
226 | } | ||
227 | } | ||
228 | |||
229 | |||
230 | // Process the file | ||
231 | |||
179 | if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH)) | 232 | if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH)) |
180 | { | 233 | { |
181 | serialisedSceneObjects.Add(Encoding.UTF8.GetString(data)); | 234 | sceneContext.SerialisedSceneObjects.Add(Encoding.UTF8.GetString(data)); |
182 | } | 235 | } |
183 | else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH) && !m_skipAssets) | 236 | else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH) && !m_skipAssets) |
184 | { | 237 | { |
@@ -192,19 +245,19 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
192 | } | 245 | } |
193 | else if (!m_merge && filePath.StartsWith(ArchiveConstants.TERRAINS_PATH)) | 246 | else if (!m_merge && filePath.StartsWith(ArchiveConstants.TERRAINS_PATH)) |
194 | { | 247 | { |
195 | LoadTerrain(filePath, data); | 248 | LoadTerrain(scene, filePath, data); |
196 | } | 249 | } |
197 | else if (!m_merge && filePath.StartsWith(ArchiveConstants.SETTINGS_PATH)) | 250 | else if (!m_merge && filePath.StartsWith(ArchiveConstants.SETTINGS_PATH)) |
198 | { | 251 | { |
199 | LoadRegionSettings(filePath, data); | 252 | LoadRegionSettings(scene, filePath, data, dearchivedScenes); |
200 | } | 253 | } |
201 | else if (!m_merge && filePath.StartsWith(ArchiveConstants.LANDDATA_PATH)) | 254 | else if (!m_merge && filePath.StartsWith(ArchiveConstants.LANDDATA_PATH)) |
202 | { | 255 | { |
203 | serialisedParcels.Add(Encoding.UTF8.GetString(data)); | 256 | sceneContext.SerialisedParcels.Add(Encoding.UTF8.GetString(data)); |
204 | } | 257 | } |
205 | else if (filePath == ArchiveConstants.CONTROL_FILE_PATH) | 258 | else if (filePath == ArchiveConstants.CONTROL_FILE_PATH) |
206 | { | 259 | { |
207 | LoadControlFile(filePath, data); | 260 | // Ignore, because we already read the control file |
208 | } | 261 | } |
209 | } | 262 | } |
210 | 263 | ||
@@ -212,15 +265,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
212 | } | 265 | } |
213 | catch (Exception e) | 266 | catch (Exception e) |
214 | { | 267 | { |
215 | m_log.ErrorFormat( | 268 | m_log.Error( |
216 | "[ARCHIVER]: Aborting load with error in archive file {0}. {1}", filePath, e); | 269 | String.Format("[ARCHIVER]: Aborting load with error in archive file {0} ", fullPath), e); |
217 | m_errorMessage += e.ToString(); | 270 | m_errorMessage += e.ToString(); |
218 | m_scene.EventManager.TriggerOarFileLoaded(m_requestId, m_errorMessage); | 271 | m_rootScene.EventManager.TriggerOarFileLoaded(m_requestId, new List<UUID>(), m_errorMessage); |
219 | return; | 272 | return; |
220 | } | 273 | } |
221 | finally | 274 | finally |
222 | { | 275 | { |
223 | archive.Close(); | 276 | if (archive != null) |
277 | archive.Close(); | ||
224 | } | 278 | } |
225 | 279 | ||
226 | if (!m_skipAssets) | 280 | if (!m_skipAssets) |
@@ -234,32 +288,143 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
234 | } | 288 | } |
235 | } | 289 | } |
236 | 290 | ||
237 | if (!m_merge) | 291 | foreach (DearchiveContext sceneContext in sceneContexts.Values) |
238 | { | 292 | { |
239 | m_log.Info("[ARCHIVER]: Clearing all existing scene objects"); | 293 | m_log.InfoFormat("[ARCHIVER:] Loading region {0}", sceneContext.Scene.RegionInfo.RegionName); |
240 | m_scene.DeleteAllSceneObjects(); | 294 | |
295 | if (!m_merge) | ||
296 | { | ||
297 | m_log.Info("[ARCHIVER]: Clearing all existing scene objects"); | ||
298 | sceneContext.Scene.DeleteAllSceneObjects(); | ||
299 | } | ||
300 | |||
301 | try | ||
302 | { | ||
303 | LoadParcels(sceneContext.Scene, sceneContext.SerialisedParcels); | ||
304 | LoadObjects(sceneContext.Scene, sceneContext.SerialisedSceneObjects, sceneContext.SceneObjects); | ||
305 | |||
306 | // Inform any interested parties that the region has changed. We waited until now so that all | ||
307 | // of the region's objects will be loaded when we send this notification. | ||
308 | IEstateModule estateModule = sceneContext.Scene.RequestModuleInterface<IEstateModule>(); | ||
309 | if (estateModule != null) | ||
310 | estateModule.TriggerRegionInfoChange(); | ||
311 | } | ||
312 | catch (Exception e) | ||
313 | { | ||
314 | m_log.Error("[ARCHIVER]: Error loading parcels or objects ", e); | ||
315 | m_errorMessage += e.ToString(); | ||
316 | m_rootScene.EventManager.TriggerOarFileLoaded(m_requestId, new List<UUID>(), m_errorMessage); | ||
317 | return; | ||
318 | } | ||
241 | } | 319 | } |
242 | 320 | ||
243 | LoadParcels(serialisedParcels); | 321 | // Start the scripts. We delayed this because we want the OAR to finish loading ASAP, so |
244 | LoadObjects(serialisedSceneObjects); | 322 | // that users can enter the scene. If we allow the scripts to start in the loop above |
323 | // then they significantly increase the time until the OAR finishes loading. | ||
324 | Util.FireAndForget(delegate(object o) | ||
325 | { | ||
326 | Thread.Sleep(15000); | ||
327 | m_log.Info("Starting scripts in scene objects"); | ||
328 | |||
329 | foreach (DearchiveContext sceneContext in sceneContexts.Values) | ||
330 | { | ||
331 | foreach (SceneObjectGroup sceneObject in sceneContext.SceneObjects) | ||
332 | { | ||
333 | sceneObject.CreateScriptInstances(0, false, sceneContext.Scene.DefaultScriptEngine, 0); // StateSource.RegionStart | ||
334 | sceneObject.ResumeScripts(); | ||
335 | } | ||
336 | |||
337 | sceneContext.SceneObjects.Clear(); | ||
338 | } | ||
339 | }); | ||
245 | 340 | ||
246 | m_log.InfoFormat("[ARCHIVER]: Successfully loaded archive"); | 341 | m_log.InfoFormat("[ARCHIVER]: Successfully loaded archive"); |
247 | 342 | ||
248 | m_scene.EventManager.TriggerOarFileLoaded(m_requestId, m_errorMessage); | 343 | m_rootScene.EventManager.TriggerOarFileLoaded(m_requestId, dearchivedScenes.GetLoadedScenes(), m_errorMessage); |
344 | } | ||
345 | |||
346 | /// <summary> | ||
347 | /// Searches through the files in the archive for the control file, and reads it. | ||
348 | /// We must read the control file first, in order to know which regions are available. | ||
349 | /// </summary> | ||
350 | /// <remarks> | ||
351 | /// In most cases the control file *is* first, since that's how we create archives. However, | ||
352 | /// it's possible that someone rewrote the archive externally so we can't rely on this fact. | ||
353 | /// </remarks> | ||
354 | /// <param name="archive"></param> | ||
355 | /// <param name="dearchivedScenes"></param> | ||
356 | private void FindAndLoadControlFile(out TarArchiveReader archive, out DearchiveScenesInfo dearchivedScenes) | ||
357 | { | ||
358 | archive = new TarArchiveReader(m_loadStream); | ||
359 | dearchivedScenes = new DearchiveScenesInfo(); | ||
360 | |||
361 | string filePath; | ||
362 | byte[] data; | ||
363 | TarArchiveReader.TarEntryType entryType; | ||
364 | bool firstFile = true; | ||
365 | |||
366 | while ((data = archive.ReadEntry(out filePath, out entryType)) != null) | ||
367 | { | ||
368 | if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType) | ||
369 | continue; | ||
370 | |||
371 | if (filePath == ArchiveConstants.CONTROL_FILE_PATH) | ||
372 | { | ||
373 | LoadControlFile(filePath, data, dearchivedScenes); | ||
374 | |||
375 | // Find which scenes are available in the simulator | ||
376 | ArchiveScenesGroup simulatorScenes = new ArchiveScenesGroup(); | ||
377 | SceneManager.Instance.ForEachScene(delegate(Scene scene2) | ||
378 | { | ||
379 | simulatorScenes.AddScene(scene2); | ||
380 | }); | ||
381 | simulatorScenes.CalcSceneLocations(); | ||
382 | dearchivedScenes.SetSimulatorScenes(m_rootScene, simulatorScenes); | ||
383 | |||
384 | // If the control file wasn't the first file then reset the read pointer | ||
385 | if (!firstFile) | ||
386 | { | ||
387 | m_log.Warn("Control file wasn't the first file in the archive"); | ||
388 | if (m_loadStream.CanSeek) | ||
389 | { | ||
390 | m_loadStream.Seek(0, SeekOrigin.Begin); | ||
391 | } | ||
392 | else if (m_loadPath != null) | ||
393 | { | ||
394 | archive.Close(); | ||
395 | archive = null; | ||
396 | m_loadStream.Close(); | ||
397 | m_loadStream = null; | ||
398 | m_loadStream = new GZipStream(ArchiveHelpers.GetStream(m_loadPath), CompressionMode.Decompress); | ||
399 | archive = new TarArchiveReader(m_loadStream); | ||
400 | } | ||
401 | else | ||
402 | { | ||
403 | // There isn't currently a scenario where this happens, but it's best to add a check just in case | ||
404 | throw new Exception("Error reading archive: control file wasn't the first file, and the input stream doesn't allow seeking"); | ||
405 | } | ||
406 | } | ||
407 | |||
408 | return; | ||
409 | } | ||
410 | |||
411 | firstFile = false; | ||
412 | } | ||
413 | |||
414 | throw new Exception("Control file not found"); | ||
249 | } | 415 | } |
250 | 416 | ||
251 | /// <summary> | 417 | /// <summary> |
252 | /// Load serialized scene objects. | 418 | /// Load serialized scene objects. |
253 | /// </summary> | 419 | /// </summary> |
254 | /// <param name="serialisedSceneObjects"></param> | 420 | protected void LoadObjects(Scene scene, List<string> serialisedSceneObjects, List<SceneObjectGroup> sceneObjects) |
255 | protected void LoadObjects(List<string> serialisedSceneObjects) | ||
256 | { | 421 | { |
257 | // Reload serialized prims | 422 | // Reload serialized prims |
258 | m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects. Please wait.", serialisedSceneObjects.Count); | 423 | m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects. Please wait.", serialisedSceneObjects.Count); |
259 | 424 | ||
260 | UUID oldTelehubUUID = m_scene.RegionInfo.RegionSettings.TelehubObject; | 425 | UUID oldTelehubUUID = scene.RegionInfo.RegionSettings.TelehubObject; |
261 | 426 | ||
262 | IRegionSerialiserModule serialiser = m_scene.RequestModuleInterface<IRegionSerialiserModule>(); | 427 | IRegionSerialiserModule serialiser = scene.RequestModuleInterface<IRegionSerialiserModule>(); |
263 | int sceneObjectsLoadedCount = 0; | 428 | int sceneObjectsLoadedCount = 0; |
264 | 429 | ||
265 | foreach (string serialisedSceneObject in serialisedSceneObjects) | 430 | foreach (string serialisedSceneObject in serialisedSceneObjects) |
@@ -280,7 +445,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
280 | 445 | ||
281 | SceneObjectGroup sceneObject = serialiser.DeserializeGroupFromXml2(serialisedSceneObject); | 446 | SceneObjectGroup sceneObject = serialiser.DeserializeGroupFromXml2(serialisedSceneObject); |
282 | 447 | ||
283 | bool isTelehub = (sceneObject.UUID == oldTelehubUUID); | 448 | bool isTelehub = (sceneObject.UUID == oldTelehubUUID) && (oldTelehubUUID != UUID.Zero); |
284 | 449 | ||
285 | // For now, give all incoming scene objects new uuids. This will allow scenes to be cloned | 450 | // For now, give all incoming scene objects new uuids. This will allow scenes to be cloned |
286 | // on the same region server and multiple examples a single object archive to be imported | 451 | // on the same region server and multiple examples a single object archive to be imported |
@@ -290,8 +455,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
290 | if (isTelehub) | 455 | if (isTelehub) |
291 | { | 456 | { |
292 | // Change the Telehub Object to the new UUID | 457 | // Change the Telehub Object to the new UUID |
293 | m_scene.RegionInfo.RegionSettings.TelehubObject = sceneObject.UUID; | 458 | scene.RegionInfo.RegionSettings.TelehubObject = sceneObject.UUID; |
294 | m_scene.RegionInfo.RegionSettings.Save(); | 459 | scene.RegionInfo.RegionSettings.Save(); |
295 | oldTelehubUUID = UUID.Zero; | 460 | oldTelehubUUID = UUID.Zero; |
296 | } | 461 | } |
297 | 462 | ||
@@ -301,17 +466,17 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
301 | { | 466 | { |
302 | if (part.CreatorData == null || part.CreatorData == string.Empty) | 467 | if (part.CreatorData == null || part.CreatorData == string.Empty) |
303 | { | 468 | { |
304 | if (!ResolveUserUuid(part.CreatorID)) | 469 | if (!ResolveUserUuid(scene, part.CreatorID)) |
305 | part.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner; | 470 | part.CreatorID = scene.RegionInfo.EstateSettings.EstateOwner; |
306 | } | 471 | } |
307 | if (UserManager != null) | 472 | if (UserManager != null) |
308 | UserManager.AddUser(part.CreatorID, part.CreatorData); | 473 | UserManager.AddUser(part.CreatorID, part.CreatorData); |
309 | 474 | ||
310 | if (!ResolveUserUuid(part.OwnerID)) | 475 | if (!ResolveUserUuid(scene, part.OwnerID)) |
311 | part.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; | 476 | part.OwnerID = scene.RegionInfo.EstateSettings.EstateOwner; |
312 | 477 | ||
313 | if (!ResolveUserUuid(part.LastOwnerID)) | 478 | if (!ResolveUserUuid(scene, part.LastOwnerID)) |
314 | part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; | 479 | part.LastOwnerID = scene.RegionInfo.EstateSettings.EstateOwner; |
315 | 480 | ||
316 | if (!ResolveGroupUuid(part.GroupID)) | 481 | if (!ResolveGroupUuid(part.GroupID)) |
317 | part.GroupID = UUID.Zero; | 482 | part.GroupID = UUID.Zero; |
@@ -325,14 +490,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
325 | // being no copy/no mod for everyone | 490 | // being no copy/no mod for everyone |
326 | lock (part.TaskInventory) | 491 | lock (part.TaskInventory) |
327 | { | 492 | { |
328 | if (!ResolveUserUuid(part.CreatorID)) | 493 | if (!ResolveUserUuid(scene, part.CreatorID)) |
329 | part.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner; | 494 | part.CreatorID = scene.RegionInfo.EstateSettings.EstateOwner; |
330 | 495 | ||
331 | if (!ResolveUserUuid(part.OwnerID)) | 496 | if (!ResolveUserUuid(scene, part.OwnerID)) |
332 | part.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; | 497 | part.OwnerID = scene.RegionInfo.EstateSettings.EstateOwner; |
333 | 498 | ||
334 | if (!ResolveUserUuid(part.LastOwnerID)) | 499 | if (!ResolveUserUuid(scene, part.LastOwnerID)) |
335 | part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; | 500 | part.LastOwnerID = scene.RegionInfo.EstateSettings.EstateOwner; |
336 | 501 | ||
337 | // And zap any troublesome sit target information | 502 | // And zap any troublesome sit target information |
338 | part.SitTargetOrientation = new Quaternion(0, 0, 0, 1); | 503 | part.SitTargetOrientation = new Quaternion(0, 0, 0, 1); |
@@ -345,15 +510,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
345 | TaskInventoryDictionary inv = part.TaskInventory; | 510 | TaskInventoryDictionary inv = part.TaskInventory; |
346 | foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv) | 511 | foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv) |
347 | { | 512 | { |
348 | if (!ResolveUserUuid(kvp.Value.OwnerID)) | 513 | if (!ResolveUserUuid(scene, kvp.Value.OwnerID)) |
349 | { | 514 | { |
350 | kvp.Value.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; | 515 | kvp.Value.OwnerID = scene.RegionInfo.EstateSettings.EstateOwner; |
351 | } | 516 | } |
352 | 517 | ||
353 | if (kvp.Value.CreatorData == null || kvp.Value.CreatorData == string.Empty) | 518 | if (kvp.Value.CreatorData == null || kvp.Value.CreatorData == string.Empty) |
354 | { | 519 | { |
355 | if (!ResolveUserUuid(kvp.Value.CreatorID)) | 520 | if (!ResolveUserUuid(scene, kvp.Value.CreatorID)) |
356 | kvp.Value.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner; | 521 | kvp.Value.CreatorID = scene.RegionInfo.EstateSettings.EstateOwner; |
357 | } | 522 | } |
358 | 523 | ||
359 | if (UserManager != null) | 524 | if (UserManager != null) |
@@ -366,10 +531,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
366 | } | 531 | } |
367 | } | 532 | } |
368 | 533 | ||
369 | if (m_scene.AddRestoredSceneObject(sceneObject, true, false)) | 534 | if (scene.AddRestoredSceneObject(sceneObject, true, false)) |
370 | { | 535 | { |
371 | sceneObjectsLoadedCount++; | 536 | sceneObjectsLoadedCount++; |
372 | sceneObject.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, 0); | 537 | sceneObject.CreateScriptInstances(0, false, scene.DefaultScriptEngine, 0); |
373 | sceneObject.ResumeScripts(); | 538 | sceneObject.ResumeScripts(); |
374 | } | 539 | } |
375 | } | 540 | } |
@@ -384,16 +549,17 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
384 | if (oldTelehubUUID != UUID.Zero) | 549 | if (oldTelehubUUID != UUID.Zero) |
385 | { | 550 | { |
386 | m_log.WarnFormat("Telehub object not found: {0}", oldTelehubUUID); | 551 | m_log.WarnFormat("Telehub object not found: {0}", oldTelehubUUID); |
387 | m_scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero; | 552 | scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero; |
388 | m_scene.RegionInfo.RegionSettings.ClearSpawnPoints(); | 553 | scene.RegionInfo.RegionSettings.ClearSpawnPoints(); |
389 | } | 554 | } |
390 | } | 555 | } |
391 | 556 | ||
392 | /// <summary> | 557 | /// <summary> |
393 | /// Load serialized parcels. | 558 | /// Load serialized parcels. |
394 | /// </summary> | 559 | /// </summary> |
560 | /// <param name="scene"></param> | ||
395 | /// <param name="serialisedParcels"></param> | 561 | /// <param name="serialisedParcels"></param> |
396 | protected void LoadParcels(List<string> serialisedParcels) | 562 | protected void LoadParcels(Scene scene, List<string> serialisedParcels) |
397 | { | 563 | { |
398 | // Reload serialized parcels | 564 | // Reload serialized parcels |
399 | m_log.InfoFormat("[ARCHIVER]: Loading {0} parcels. Please wait.", serialisedParcels.Count); | 565 | m_log.InfoFormat("[ARCHIVER]: Loading {0} parcels. Please wait.", serialisedParcels.Count); |
@@ -404,8 +570,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
404 | 570 | ||
405 | // Validate User and Group UUID's | 571 | // Validate User and Group UUID's |
406 | 572 | ||
407 | if (!ResolveUserUuid(parcel.OwnerID)) | 573 | if (!ResolveUserUuid(scene, parcel.OwnerID)) |
408 | parcel.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; | 574 | parcel.OwnerID = m_rootScene.RegionInfo.EstateSettings.EstateOwner; |
409 | 575 | ||
410 | if (!ResolveGroupUuid(parcel.GroupID)) | 576 | if (!ResolveGroupUuid(parcel.GroupID)) |
411 | { | 577 | { |
@@ -416,7 +582,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
416 | List<LandAccessEntry> accessList = new List<LandAccessEntry>(); | 582 | List<LandAccessEntry> accessList = new List<LandAccessEntry>(); |
417 | foreach (LandAccessEntry entry in parcel.ParcelAccessList) | 583 | foreach (LandAccessEntry entry in parcel.ParcelAccessList) |
418 | { | 584 | { |
419 | if (ResolveUserUuid(entry.AgentID)) | 585 | if (ResolveUserUuid(scene, entry.AgentID)) |
420 | accessList.Add(entry); | 586 | accessList.Add(entry); |
421 | // else, drop this access rule | 587 | // else, drop this access rule |
422 | } | 588 | } |
@@ -432,23 +598,24 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
432 | if (!m_merge) | 598 | if (!m_merge) |
433 | { | 599 | { |
434 | bool setupDefaultParcel = (landData.Count == 0); | 600 | bool setupDefaultParcel = (landData.Count == 0); |
435 | m_scene.LandChannel.Clear(setupDefaultParcel); | 601 | scene.LandChannel.Clear(setupDefaultParcel); |
436 | } | 602 | } |
437 | 603 | ||
438 | m_scene.EventManager.TriggerIncomingLandDataFromStorage(landData); | 604 | scene.EventManager.TriggerIncomingLandDataFromStorage(landData); |
439 | m_log.InfoFormat("[ARCHIVER]: Restored {0} parcels.", landData.Count); | 605 | m_log.InfoFormat("[ARCHIVER]: Restored {0} parcels.", landData.Count); |
440 | } | 606 | } |
441 | 607 | ||
442 | /// <summary> | 608 | /// <summary> |
443 | /// Look up the given user id to check whether it's one that is valid for this grid. | 609 | /// Look up the given user id to check whether it's one that is valid for this grid. |
444 | /// </summary> | 610 | /// </summary> |
611 | /// <param name="scene"></param> | ||
445 | /// <param name="uuid"></param> | 612 | /// <param name="uuid"></param> |
446 | /// <returns></returns> | 613 | /// <returns></returns> |
447 | private bool ResolveUserUuid(UUID uuid) | 614 | private bool ResolveUserUuid(Scene scene, UUID uuid) |
448 | { | 615 | { |
449 | if (!m_validUserUuids.ContainsKey(uuid)) | 616 | if (!m_validUserUuids.ContainsKey(uuid)) |
450 | { | 617 | { |
451 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, uuid); | 618 | UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, uuid); |
452 | m_validUserUuids.Add(uuid, account != null); | 619 | m_validUserUuids.Add(uuid, account != null); |
453 | } | 620 | } |
454 | 621 | ||
@@ -503,7 +670,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
503 | string extension = filename.Substring(i); | 670 | string extension = filename.Substring(i); |
504 | string uuid = filename.Remove(filename.Length - extension.Length); | 671 | string uuid = filename.Remove(filename.Length - extension.Length); |
505 | 672 | ||
506 | if (m_scene.AssetService.GetMetadata(uuid) != null) | 673 | if (m_assetService.GetMetadata(uuid) != null) |
507 | { | 674 | { |
508 | // m_log.DebugFormat("[ARCHIVER]: found existing asset {0}",uuid); | 675 | // m_log.DebugFormat("[ARCHIVER]: found existing asset {0}",uuid); |
509 | return true; | 676 | return true; |
@@ -523,7 +690,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
523 | 690 | ||
524 | // We're relying on the asset service to do the sensible thing and not store the asset if it already | 691 | // We're relying on the asset service to do the sensible thing and not store the asset if it already |
525 | // exists. | 692 | // exists. |
526 | m_scene.AssetService.Store(asset); | 693 | m_assetService.Store(asset); |
527 | 694 | ||
528 | /** | 695 | /** |
529 | * Create layers on decode for image assets. This is likely to significantly increase the time to load archives so | 696 | * Create layers on decode for image assets. This is likely to significantly increase the time to load archives so |
@@ -551,12 +718,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
551 | /// <summary> | 718 | /// <summary> |
552 | /// Load region settings data | 719 | /// Load region settings data |
553 | /// </summary> | 720 | /// </summary> |
721 | /// <param name="scene"></param> | ||
554 | /// <param name="settingsPath"></param> | 722 | /// <param name="settingsPath"></param> |
555 | /// <param name="data"></param> | 723 | /// <param name="data"></param> |
724 | /// <param name="dearchivedScenes"></param> | ||
556 | /// <returns> | 725 | /// <returns> |
557 | /// true if settings were loaded successfully, false otherwise | 726 | /// true if settings were loaded successfully, false otherwise |
558 | /// </returns> | 727 | /// </returns> |
559 | private bool LoadRegionSettings(string settingsPath, byte[] data) | 728 | private bool LoadRegionSettings(Scene scene, string settingsPath, byte[] data, DearchiveScenesInfo dearchivedScenes) |
560 | { | 729 | { |
561 | RegionSettings loadedRegionSettings; | 730 | RegionSettings loadedRegionSettings; |
562 | 731 | ||
@@ -572,7 +741,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
572 | return false; | 741 | return false; |
573 | } | 742 | } |
574 | 743 | ||
575 | RegionSettings currentRegionSettings = m_scene.RegionInfo.RegionSettings; | 744 | RegionSettings currentRegionSettings = scene.RegionInfo.RegionSettings; |
576 | 745 | ||
577 | currentRegionSettings.AgentLimit = loadedRegionSettings.AgentLimit; | 746 | currentRegionSettings.AgentLimit = loadedRegionSettings.AgentLimit; |
578 | currentRegionSettings.AllowDamage = loadedRegionSettings.AllowDamage; | 747 | currentRegionSettings.AllowDamage = loadedRegionSettings.AllowDamage; |
@@ -609,12 +778,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
609 | foreach (SpawnPoint sp in loadedRegionSettings.SpawnPoints()) | 778 | foreach (SpawnPoint sp in loadedRegionSettings.SpawnPoints()) |
610 | currentRegionSettings.AddSpawnPoint(sp); | 779 | currentRegionSettings.AddSpawnPoint(sp); |
611 | 780 | ||
781 | currentRegionSettings.LoadedCreationDateTime = dearchivedScenes.LoadedCreationDateTime; | ||
782 | currentRegionSettings.LoadedCreationID = dearchivedScenes.GetOriginalRegionID(scene.RegionInfo.RegionID).ToString(); | ||
783 | |||
612 | currentRegionSettings.Save(); | 784 | currentRegionSettings.Save(); |
613 | 785 | ||
614 | m_scene.TriggerEstateSunUpdate(); | 786 | scene.TriggerEstateSunUpdate(); |
615 | 787 | ||
616 | IEstateModule estateModule = m_scene.RequestModuleInterface<IEstateModule>(); | 788 | IEstateModule estateModule = scene.RequestModuleInterface<IEstateModule>(); |
617 | |||
618 | if (estateModule != null) | 789 | if (estateModule != null) |
619 | estateModule.sendRegionHandshakeToAll(); | 790 | estateModule.sendRegionHandshakeToAll(); |
620 | 791 | ||
@@ -624,14 +795,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
624 | /// <summary> | 795 | /// <summary> |
625 | /// Load terrain data | 796 | /// Load terrain data |
626 | /// </summary> | 797 | /// </summary> |
798 | /// <param name="scene"></param> | ||
627 | /// <param name="terrainPath"></param> | 799 | /// <param name="terrainPath"></param> |
628 | /// <param name="data"></param> | 800 | /// <param name="data"></param> |
629 | /// <returns> | 801 | /// <returns> |
630 | /// true if terrain was resolved successfully, false otherwise. | 802 | /// true if terrain was resolved successfully, false otherwise. |
631 | /// </returns> | 803 | /// </returns> |
632 | private bool LoadTerrain(string terrainPath, byte[] data) | 804 | private bool LoadTerrain(Scene scene, string terrainPath, byte[] data) |
633 | { | 805 | { |
634 | ITerrainModule terrainModule = m_scene.RequestModuleInterface<ITerrainModule>(); | 806 | ITerrainModule terrainModule = scene.RequestModuleInterface<ITerrainModule>(); |
635 | 807 | ||
636 | MemoryStream ms = new MemoryStream(data); | 808 | MemoryStream ms = new MemoryStream(data); |
637 | terrainModule.LoadFromStream(terrainPath, ms); | 809 | terrainModule.LoadFromStream(terrainPath, ms); |
@@ -647,17 +819,18 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
647 | /// </summary> | 819 | /// </summary> |
648 | /// <param name="path"></param> | 820 | /// <param name="path"></param> |
649 | /// <param name="data"></param> | 821 | /// <param name="data"></param> |
650 | public void LoadControlFile(string path, byte[] data) | 822 | /// <param name="dearchivedScenes"></param> |
823 | public DearchiveScenesInfo LoadControlFile(string path, byte[] data, DearchiveScenesInfo dearchivedScenes) | ||
651 | { | 824 | { |
652 | XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable()); | 825 | XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable()); |
653 | XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None); | 826 | XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None); |
654 | XmlTextReader xtr = new XmlTextReader(Encoding.ASCII.GetString(data), XmlNodeType.Document, context); | 827 | XmlTextReader xtr = new XmlTextReader(Encoding.ASCII.GetString(data), XmlNodeType.Document, context); |
655 | 828 | ||
656 | RegionSettings currentRegionSettings = m_scene.RegionInfo.RegionSettings; | 829 | // Loaded metadata will be empty if no information exists in the archive |
830 | dearchivedScenes.LoadedCreationDateTime = 0; | ||
831 | dearchivedScenes.DefaultOriginalID = ""; | ||
657 | 832 | ||
658 | // Loaded metadata will empty if no information exists in the archive | 833 | bool multiRegion = false; |
659 | currentRegionSettings.LoadedCreationDateTime = 0; | ||
660 | currentRegionSettings.LoadedCreationID = ""; | ||
661 | 834 | ||
662 | while (xtr.Read()) | 835 | while (xtr.Read()) |
663 | { | 836 | { |
@@ -683,18 +856,44 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
683 | { | 856 | { |
684 | int value; | 857 | int value; |
685 | if (Int32.TryParse(xtr.ReadElementContentAsString(), out value)) | 858 | if (Int32.TryParse(xtr.ReadElementContentAsString(), out value)) |
686 | currentRegionSettings.LoadedCreationDateTime = value; | 859 | dearchivedScenes.LoadedCreationDateTime = value; |
687 | } | 860 | } |
688 | else if (xtr.Name.ToString() == "id") | 861 | else if (xtr.Name.ToString() == "row") |
862 | { | ||
863 | multiRegion = true; | ||
864 | dearchivedScenes.StartRow(); | ||
865 | } | ||
866 | else if (xtr.Name.ToString() == "region") | ||
689 | { | 867 | { |
690 | currentRegionSettings.LoadedCreationID = xtr.ReadElementContentAsString(); | 868 | dearchivedScenes.StartRegion(); |
869 | } | ||
870 | else if (xtr.Name.ToString() == "id") | ||
871 | { | ||
872 | string id = xtr.ReadElementContentAsString(); | ||
873 | dearchivedScenes.DefaultOriginalID = id; | ||
874 | if (multiRegion) | ||
875 | dearchivedScenes.SetRegionOriginalID(id); | ||
876 | } | ||
877 | else if (xtr.Name.ToString() == "dir") | ||
878 | { | ||
879 | dearchivedScenes.SetRegionDirectory(xtr.ReadElementContentAsString()); | ||
691 | } | 880 | } |
692 | } | 881 | } |
693 | } | 882 | } |
694 | 883 | ||
695 | currentRegionSettings.Save(); | 884 | dearchivedScenes.MultiRegionFormat = multiRegion; |
696 | 885 | if (!multiRegion) | |
886 | { | ||
887 | // Add the single scene | ||
888 | dearchivedScenes.StartRow(); | ||
889 | dearchivedScenes.StartRegion(); | ||
890 | dearchivedScenes.SetRegionOriginalID(dearchivedScenes.DefaultOriginalID); | ||
891 | dearchivedScenes.SetRegionDirectory(""); | ||
892 | } | ||
893 | |||
697 | ControlFileLoaded = true; | 894 | ControlFileLoaded = true; |
895 | |||
896 | return dearchivedScenes; | ||
698 | } | 897 | } |
699 | } | 898 | } |
700 | } \ No newline at end of file | 899 | } |