mirror of
https://github.com/opensim/opensim.git
synced 2026-08-06 17:32:42 +08:00
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/Framework/Scenes/Scene.cs OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs
This commit is contained in:
@@ -67,7 +67,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
/// Determine whether this archive will save assets. Default is true.
|
||||
/// </summary>
|
||||
public bool SaveAssets { get; set; }
|
||||
|
||||
|
||||
protected ArchiverModule m_module;
|
||||
protected Scene m_scene;
|
||||
protected Stream m_saveStream;
|
||||
protected Guid m_requestId;
|
||||
@@ -75,13 +76,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="scene"></param>
|
||||
/// <param name="module">Calling module</param>
|
||||
/// <param name="savePath">The path to which to save data.</param>
|
||||
/// <param name="requestId">The id associated with this request</param>
|
||||
/// <exception cref="System.IO.IOException">
|
||||
/// If there was a problem opening a stream for the file specified by the savePath
|
||||
/// </exception>
|
||||
public ArchiveWriteRequestPreparation(Scene scene, string savePath, Guid requestId) : this(scene, requestId)
|
||||
public ArchiveWriteRequestPreparation(ArchiverModule module, string savePath, Guid requestId) : this(module, requestId)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -99,17 +100,23 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
/// <param name="scene"></param>
|
||||
/// <param name="module">Calling module</param>
|
||||
/// <param name="saveStream">The stream to which to save data.</param>
|
||||
/// <param name="requestId">The id associated with this request</param>
|
||||
public ArchiveWriteRequestPreparation(Scene scene, Stream saveStream, Guid requestId) : this(scene, requestId)
|
||||
public ArchiveWriteRequestPreparation(ArchiverModule module, Stream saveStream, Guid requestId) : this(module, requestId)
|
||||
{
|
||||
m_saveStream = saveStream;
|
||||
}
|
||||
|
||||
protected ArchiveWriteRequestPreparation(Scene scene, Guid requestId)
|
||||
protected ArchiveWriteRequestPreparation(ArchiverModule module, Guid requestId)
|
||||
{
|
||||
m_scene = scene;
|
||||
m_module = module;
|
||||
|
||||
// FIXME: This is only here for regression test purposes since they do not supply a module. Need to fix
|
||||
// this.
|
||||
if (m_module != null)
|
||||
m_scene = m_module.Scene;
|
||||
|
||||
m_requestId = requestId;
|
||||
|
||||
SaveAssets = true;
|
||||
@@ -364,32 +371,56 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
//if (majorVersion == 1)
|
||||
//{
|
||||
// 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");
|
||||
//}
|
||||
//}
|
||||
|
||||
String s;
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
XmlTextWriter xtw = new XmlTextWriter(sw);
|
||||
xtw.Formatting = Formatting.Indented;
|
||||
xtw.WriteStartDocument();
|
||||
xtw.WriteStartElement("archive");
|
||||
xtw.WriteAttributeString("major_version", majorVersion.ToString());
|
||||
xtw.WriteAttributeString("minor_version", minorVersion.ToString());
|
||||
using (StringWriter sw = new StringWriter())
|
||||
{
|
||||
using (XmlTextWriter xtw = new XmlTextWriter(sw))
|
||||
{
|
||||
xtw.Formatting = Formatting.Indented;
|
||||
xtw.WriteStartDocument();
|
||||
xtw.WriteStartElement("archive");
|
||||
xtw.WriteAttributeString("major_version", majorVersion.ToString());
|
||||
xtw.WriteAttributeString("minor_version", minorVersion.ToString());
|
||||
|
||||
xtw.WriteStartElement("creation_info");
|
||||
DateTime now = DateTime.UtcNow;
|
||||
TimeSpan t = now - new DateTime(1970, 1, 1);
|
||||
xtw.WriteElementString("datetime", ((int)t.TotalSeconds).ToString());
|
||||
xtw.WriteElementString("id", UUID.Random().ToString());
|
||||
xtw.WriteEndElement();
|
||||
|
||||
xtw.WriteElementString("assets_included", SaveAssets.ToString());
|
||||
|
||||
bool isMegaregion;
|
||||
|
||||
xtw.WriteStartElement("creation_info");
|
||||
DateTime now = DateTime.UtcNow;
|
||||
TimeSpan t = now - new DateTime(1970, 1, 1);
|
||||
xtw.WriteElementString("datetime", ((int)t.TotalSeconds).ToString());
|
||||
xtw.WriteElementString("id", UUID.Random().ToString());
|
||||
xtw.WriteEndElement();
|
||||
// FIXME: This is only here for regression test purposes since they do not supply a module. Need to fix
|
||||
// this, possibly by doing control file creation somewhere else.
|
||||
if (m_module != null && m_module.RegionCombinerModule != null)
|
||||
{
|
||||
IRegionCombinerModule mod = m_module.RegionCombinerModule;
|
||||
isMegaregion = mod.IsRootForMegaregion(m_scene.RegionInfo.RegionID);
|
||||
}
|
||||
else
|
||||
{
|
||||
isMegaregion = false;
|
||||
}
|
||||
|
||||
xtw.WriteElementString("is_megaregion", isMegaregion.ToString());
|
||||
|
||||
xtw.WriteEndElement();
|
||||
|
||||
xtw.Flush();
|
||||
xtw.Close();
|
||||
}
|
||||
|
||||
xtw.WriteElementString("assets_included", SaveAssets.ToString());
|
||||
s = sw.ToString();
|
||||
}
|
||||
|
||||
xtw.WriteEndElement();
|
||||
|
||||
xtw.Flush();
|
||||
xtw.Close();
|
||||
|
||||
String s = sw.ToString();
|
||||
sw.Close();
|
||||
// Console.WriteLine(
|
||||
// "[ARCHIVE WRITE REQUEST PREPARATION]: Control file for {0} is: {1}", m_scene.RegionInfo.RegionName, s);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private Scene m_scene;
|
||||
public Scene Scene { get; private set; }
|
||||
public IRegionCombinerModule RegionCombinerModule { get; private set; }
|
||||
|
||||
/// <value>
|
||||
/// The file used to load and save an opensimulator archive if no filename has been specified
|
||||
@@ -70,13 +71,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
|
||||
public void AddRegion(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
m_scene.RegisterModuleInterface<IRegionArchiverModule>(this);
|
||||
Scene = scene;
|
||||
Scene.RegisterModuleInterface<IRegionArchiverModule>(this);
|
||||
//m_log.DebugFormat("[ARCHIVER]: Enabled for region {0}", scene.RegionInfo.RegionName);
|
||||
}
|
||||
|
||||
public void RegionLoaded(Scene scene)
|
||||
{
|
||||
RegionCombinerModule = scene.RequestModuleInterface<IRegionCombinerModule>();
|
||||
}
|
||||
|
||||
public void RemoveRegion(Scene scene)
|
||||
@@ -165,9 +167,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
public void ArchiveRegion(string savePath, Guid requestId, Dictionary<string, object> options)
|
||||
{
|
||||
m_log.InfoFormat(
|
||||
"[ARCHIVER]: Writing archive for region {0} to {1}", m_scene.RegionInfo.RegionName, savePath);
|
||||
"[ARCHIVER]: Writing archive for region {0} to {1}", Scene.RegionInfo.RegionName, savePath);
|
||||
|
||||
new ArchiveWriteRequestPreparation(m_scene, savePath, requestId).ArchiveRegion(options);
|
||||
new ArchiveWriteRequestPreparation(this, savePath, requestId).ArchiveRegion(options);
|
||||
}
|
||||
|
||||
public void ArchiveRegion(Stream saveStream)
|
||||
@@ -182,7 +184,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
|
||||
public void ArchiveRegion(Stream saveStream, Guid requestId, Dictionary<string, object> options)
|
||||
{
|
||||
new ArchiveWriteRequestPreparation(m_scene, saveStream, requestId).ArchiveRegion(options);
|
||||
new ArchiveWriteRequestPreparation(this, saveStream, requestId).ArchiveRegion(options);
|
||||
}
|
||||
|
||||
public void DearchiveRegion(string loadPath)
|
||||
@@ -193,9 +195,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
public void DearchiveRegion(string loadPath, bool merge, bool skipAssets, Guid requestId)
|
||||
{
|
||||
m_log.InfoFormat(
|
||||
"[ARCHIVER]: Loading archive to region {0} from {1}", m_scene.RegionInfo.RegionName, loadPath);
|
||||
"[ARCHIVER]: Loading archive to region {0} from {1}", Scene.RegionInfo.RegionName, loadPath);
|
||||
|
||||
new ArchiveReadRequest(m_scene, loadPath, merge, skipAssets, requestId).DearchiveRegion();
|
||||
new ArchiveReadRequest(Scene, loadPath, merge, skipAssets, requestId).DearchiveRegion();
|
||||
}
|
||||
|
||||
public void DearchiveRegion(Stream loadStream)
|
||||
@@ -205,7 +207,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
|
||||
public void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Guid requestId)
|
||||
{
|
||||
new ArchiveReadRequest(m_scene, loadStream, merge, skipAssets, requestId).DearchiveRegion();
|
||||
new ArchiveReadRequest(Scene, loadStream, merge, skipAssets, requestId).DearchiveRegion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user