diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs | 95 |
1 files changed, 63 insertions, 32 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs index 5679ad5..e54774b 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs | |||
@@ -67,7 +67,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
67 | /// Determine whether this archive will save assets. Default is true. | 67 | /// Determine whether this archive will save assets. Default is true. |
68 | /// </summary> | 68 | /// </summary> |
69 | public bool SaveAssets { get; set; } | 69 | public bool SaveAssets { get; set; } |
70 | 70 | ||
71 | protected ArchiverModule m_module; | ||
71 | protected Scene m_scene; | 72 | protected Scene m_scene; |
72 | protected Stream m_saveStream; | 73 | protected Stream m_saveStream; |
73 | protected Guid m_requestId; | 74 | protected Guid m_requestId; |
@@ -75,13 +76,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
75 | /// <summary> | 76 | /// <summary> |
76 | /// Constructor | 77 | /// Constructor |
77 | /// </summary> | 78 | /// </summary> |
78 | /// <param name="scene"></param> | 79 | /// <param name="module">Calling module</param> |
79 | /// <param name="savePath">The path to which to save data.</param> | 80 | /// <param name="savePath">The path to which to save data.</param> |
80 | /// <param name="requestId">The id associated with this request</param> | 81 | /// <param name="requestId">The id associated with this request</param> |
81 | /// <exception cref="System.IO.IOException"> | 82 | /// <exception cref="System.IO.IOException"> |
82 | /// If there was a problem opening a stream for the file specified by the savePath | 83 | /// If there was a problem opening a stream for the file specified by the savePath |
83 | /// </exception> | 84 | /// </exception> |
84 | public ArchiveWriteRequestPreparation(Scene scene, string savePath, Guid requestId) : this(scene, requestId) | 85 | public ArchiveWriteRequestPreparation(ArchiverModule module, string savePath, Guid requestId) : this(module, requestId) |
85 | { | 86 | { |
86 | try | 87 | try |
87 | { | 88 | { |
@@ -99,17 +100,23 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
99 | /// <summary> | 100 | /// <summary> |
100 | /// Constructor. | 101 | /// Constructor. |
101 | /// </summary> | 102 | /// </summary> |
102 | /// <param name="scene"></param> | 103 | /// <param name="module">Calling module</param> |
103 | /// <param name="saveStream">The stream to which to save data.</param> | 104 | /// <param name="saveStream">The stream to which to save data.</param> |
104 | /// <param name="requestId">The id associated with this request</param> | 105 | /// <param name="requestId">The id associated with this request</param> |
105 | public ArchiveWriteRequestPreparation(Scene scene, Stream saveStream, Guid requestId) : this(scene, requestId) | 106 | public ArchiveWriteRequestPreparation(ArchiverModule module, Stream saveStream, Guid requestId) : this(module, requestId) |
106 | { | 107 | { |
107 | m_saveStream = saveStream; | 108 | m_saveStream = saveStream; |
108 | } | 109 | } |
109 | 110 | ||
110 | protected ArchiveWriteRequestPreparation(Scene scene, Guid requestId) | 111 | protected ArchiveWriteRequestPreparation(ArchiverModule module, Guid requestId) |
111 | { | 112 | { |
112 | m_scene = scene; | 113 | m_module = module; |
114 | |||
115 | // FIXME: This is only here for regression test purposes since they do not supply a module. Need to fix | ||
116 | // this. | ||
117 | if (m_module != null) | ||
118 | m_scene = m_module.Scene; | ||
119 | |||
113 | m_requestId = requestId; | 120 | m_requestId = requestId; |
114 | 121 | ||
115 | SaveAssets = true; | 122 | SaveAssets = true; |
@@ -364,32 +371,56 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
364 | //if (majorVersion == 1) | 371 | //if (majorVersion == 1) |
365 | //{ | 372 | //{ |
366 | // m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR"); | 373 | // m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR"); |
367 | //} | 374 | //} |
375 | |||
376 | String s; | ||
368 | 377 | ||
369 | StringWriter sw = new StringWriter(); | 378 | using (StringWriter sw = new StringWriter()) |
370 | XmlTextWriter xtw = new XmlTextWriter(sw); | 379 | { |
371 | xtw.Formatting = Formatting.Indented; | 380 | using (XmlTextWriter xtw = new XmlTextWriter(sw)) |
372 | xtw.WriteStartDocument(); | 381 | { |
373 | xtw.WriteStartElement("archive"); | 382 | xtw.Formatting = Formatting.Indented; |
374 | xtw.WriteAttributeString("major_version", majorVersion.ToString()); | 383 | xtw.WriteStartDocument(); |
375 | xtw.WriteAttributeString("minor_version", minorVersion.ToString()); | 384 | xtw.WriteStartElement("archive"); |
376 | 385 | xtw.WriteAttributeString("major_version", majorVersion.ToString()); | |
377 | xtw.WriteStartElement("creation_info"); | 386 | xtw.WriteAttributeString("minor_version", minorVersion.ToString()); |
378 | DateTime now = DateTime.UtcNow; | 387 | |
379 | TimeSpan t = now - new DateTime(1970, 1, 1); | 388 | xtw.WriteStartElement("creation_info"); |
380 | xtw.WriteElementString("datetime", ((int)t.TotalSeconds).ToString()); | 389 | DateTime now = DateTime.UtcNow; |
381 | xtw.WriteElementString("id", UUID.Random().ToString()); | 390 | TimeSpan t = now - new DateTime(1970, 1, 1); |
382 | xtw.WriteEndElement(); | 391 | xtw.WriteElementString("datetime", ((int)t.TotalSeconds).ToString()); |
383 | 392 | xtw.WriteElementString("id", UUID.Random().ToString()); | |
384 | xtw.WriteElementString("assets_included", SaveAssets.ToString()); | 393 | xtw.WriteEndElement(); |
385 | 394 | ||
386 | xtw.WriteEndElement(); | 395 | xtw.WriteElementString("assets_included", SaveAssets.ToString()); |
387 | 396 | ||
388 | xtw.Flush(); | 397 | bool isMegaregion; |
389 | xtw.Close(); | 398 | |
390 | 399 | // FIXME: This is only here for regression test purposes since they do not supply a module. Need to fix | |
391 | String s = sw.ToString(); | 400 | // this, possibly by doing control file creation somewhere else. |
392 | sw.Close(); | 401 | if (m_module != null && m_module.RegionCombinerModule != null) |
402 | { | ||
403 | IRegionCombinerModule mod = m_module.RegionCombinerModule; | ||
404 | isMegaregion = mod.IsRootForMegaregion(m_scene.RegionInfo.RegionID); | ||
405 | } | ||
406 | else | ||
407 | { | ||
408 | isMegaregion = false; | ||
409 | } | ||
410 | |||
411 | xtw.WriteElementString("is_megaregion", isMegaregion.ToString()); | ||
412 | |||
413 | xtw.WriteEndElement(); | ||
414 | |||
415 | xtw.Flush(); | ||
416 | xtw.Close(); | ||
417 | } | ||
418 | |||
419 | s = sw.ToString(); | ||
420 | } | ||
421 | |||
422 | // Console.WriteLine( | ||
423 | // "[ARCHIVE WRITE REQUEST PREPARATION]: Control file for {0} is: {1}", m_scene.RegionInfo.RegionName, s); | ||
393 | 424 | ||
394 | return s; | 425 | return s; |
395 | } | 426 | } |