Merge branch 'master' of /var/git/opensim/
commit
4ec0933c99
|
@ -265,9 +265,9 @@ namespace OpenSim
|
||||||
LoadOar);
|
LoadOar);
|
||||||
|
|
||||||
m_console.Commands.AddCommand("region", false, "save oar",
|
m_console.Commands.AddCommand("region", false, "save oar",
|
||||||
"save oar [-v|version=N] [<OAR path>]",
|
"save oar [-v|--version=N] [<OAR path>]",
|
||||||
"Save a region's data to an OAR archive.",
|
"Save a region's data to an OAR archive.",
|
||||||
"-v|version=N generates scene objects as per older versions of the serialization (e.g. -v=0)" + Environment.NewLine
|
"-v|--version=N generates scene objects as per older versions of the serialization (e.g. -v=0)" + Environment.NewLine
|
||||||
+ "The OAR path must be a filesystem path."
|
+ "The OAR path must be a filesystem path."
|
||||||
+ " If this is not given then the oar is saved to region.oar in the current directory.",
|
+ " If this is not given then the oar is saved to region.oar in the current directory.",
|
||||||
SaveOar);
|
SaveOar);
|
||||||
|
|
|
@ -49,7 +49,17 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||||
public class ArchiveWriteRequestPreparation
|
public class ArchiveWriteRequestPreparation
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The minimum major version of OAR that we can write.
|
||||||
|
/// </summary>
|
||||||
|
public static int MIN_MAJOR_VERSION = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The maximum major version of OAR that we can write.
|
||||||
|
/// </summary>
|
||||||
|
public static int MAX_MAJOR_VERSION = 1;
|
||||||
|
|
||||||
protected Scene m_scene;
|
protected Scene m_scene;
|
||||||
protected Stream m_saveStream;
|
protected Stream m_saveStream;
|
||||||
protected Guid m_requestId;
|
protected Guid m_requestId;
|
||||||
|
@ -101,110 +111,136 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||||
/// <exception cref="System.IO.IOException">if there was an io problem with creating the file</exception>
|
/// <exception cref="System.IO.IOException">if there was an io problem with creating the file</exception>
|
||||||
public void ArchiveRegion(Dictionary<string, object> options)
|
public void ArchiveRegion(Dictionary<string, object> options)
|
||||||
{
|
{
|
||||||
Dictionary<UUID, AssetType> assetUuids = new Dictionary<UUID, AssetType>();
|
try
|
||||||
|
{
|
||||||
EntityBase[] entities = m_scene.GetEntities();
|
Dictionary<UUID, AssetType> assetUuids = new Dictionary<UUID, AssetType>();
|
||||||
List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
|
|
||||||
|
EntityBase[] entities = m_scene.GetEntities();
|
||||||
/*
|
List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
|
||||||
foreach (ILandObject lo in m_scene.LandChannel.AllParcels())
|
|
||||||
{
|
/*
|
||||||
if (name == lo.LandData.Name)
|
foreach (ILandObject lo in m_scene.LandChannel.AllParcels())
|
||||||
{
|
{
|
||||||
// This is the parcel we want
|
if (name == lo.LandData.Name)
|
||||||
|
{
|
||||||
|
// This is the parcel we want
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Filter entities so that we only have scene objects.
|
||||||
|
// FIXME: Would be nicer to have this as a proper list in SceneGraph, since lots of methods
|
||||||
|
// end up having to do this
|
||||||
|
foreach (EntityBase entity in entities)
|
||||||
|
{
|
||||||
|
if (entity is SceneObjectGroup)
|
||||||
|
{
|
||||||
|
SceneObjectGroup sceneObject = (SceneObjectGroup)entity;
|
||||||
|
|
||||||
|
if (!sceneObject.IsDeleted && !sceneObject.IsAttachment)
|
||||||
|
sceneObjects.Add((SceneObjectGroup)entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
UuidGatherer assetGatherer = new UuidGatherer(m_scene.AssetService);
|
||||||
// Filter entities so that we only have scene objects.
|
|
||||||
// FIXME: Would be nicer to have this as a proper list in SceneGraph, since lots of methods
|
foreach (SceneObjectGroup sceneObject in sceneObjects)
|
||||||
// end up having to do this
|
|
||||||
foreach (EntityBase entity in entities)
|
|
||||||
{
|
|
||||||
if (entity is SceneObjectGroup)
|
|
||||||
{
|
{
|
||||||
SceneObjectGroup sceneObject = (SceneObjectGroup)entity;
|
assetGatherer.GatherAssetUuids(sceneObject, assetUuids);
|
||||||
|
|
||||||
if (!sceneObject.IsDeleted && !sceneObject.IsAttachment)
|
|
||||||
sceneObjects.Add((SceneObjectGroup)entity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_log.DebugFormat(
|
||||||
|
"[ARCHIVER]: {0} scene objects to serialize requiring save of {1} assets",
|
||||||
|
sceneObjects.Count, assetUuids.Count);
|
||||||
|
|
||||||
|
// Make sure that we also request terrain texture assets
|
||||||
|
RegionSettings regionSettings = m_scene.RegionInfo.RegionSettings;
|
||||||
|
|
||||||
|
if (regionSettings.TerrainTexture1 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_1)
|
||||||
|
assetUuids[regionSettings.TerrainTexture1] = AssetType.Texture;
|
||||||
|
|
||||||
|
if (regionSettings.TerrainTexture2 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_2)
|
||||||
|
assetUuids[regionSettings.TerrainTexture2] = AssetType.Texture;
|
||||||
|
|
||||||
|
if (regionSettings.TerrainTexture3 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_3)
|
||||||
|
assetUuids[regionSettings.TerrainTexture3] = AssetType.Texture;
|
||||||
|
|
||||||
|
if (regionSettings.TerrainTexture4 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_4)
|
||||||
|
assetUuids[regionSettings.TerrainTexture4] = AssetType.Texture;
|
||||||
|
|
||||||
|
TarArchiveWriter archiveWriter = new TarArchiveWriter(m_saveStream);
|
||||||
|
|
||||||
|
// Asynchronously request all the assets required to perform this archive operation
|
||||||
|
ArchiveWriteRequestExecution awre
|
||||||
|
= new ArchiveWriteRequestExecution(
|
||||||
|
sceneObjects,
|
||||||
|
m_scene.RequestModuleInterface<ITerrainModule>(),
|
||||||
|
m_scene.RequestModuleInterface<IRegionSerialiserModule>(),
|
||||||
|
m_scene,
|
||||||
|
archiveWriter,
|
||||||
|
m_requestId,
|
||||||
|
options);
|
||||||
|
|
||||||
|
m_log.InfoFormat("[ARCHIVER]: Creating archive file. This may take some time.");
|
||||||
|
|
||||||
|
// Write out control file. This has to be done first so that subsequent loaders will see this file first
|
||||||
|
// XXX: I know this is a weak way of doing it since external non-OAR aware tar executables will not do this
|
||||||
|
archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, CreateControlFile(options));
|
||||||
|
m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");
|
||||||
|
|
||||||
|
new AssetsRequest(
|
||||||
|
new AssetsArchiver(archiveWriter), assetUuids,
|
||||||
|
m_scene.AssetService, awre.ReceivedAllAssets).Execute();
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
UuidGatherer assetGatherer = new UuidGatherer(m_scene.AssetService);
|
|
||||||
|
|
||||||
foreach (SceneObjectGroup sceneObject in sceneObjects)
|
|
||||||
{
|
{
|
||||||
assetGatherer.GatherAssetUuids(sceneObject, assetUuids);
|
m_saveStream.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_log.DebugFormat(
|
|
||||||
"[ARCHIVER]: {0} scene objects to serialize requiring save of {1} assets",
|
|
||||||
sceneObjects.Count, assetUuids.Count);
|
|
||||||
|
|
||||||
// Make sure that we also request terrain texture assets
|
|
||||||
RegionSettings regionSettings = m_scene.RegionInfo.RegionSettings;
|
|
||||||
|
|
||||||
if (regionSettings.TerrainTexture1 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_1)
|
|
||||||
assetUuids[regionSettings.TerrainTexture1] = AssetType.Texture;
|
|
||||||
|
|
||||||
if (regionSettings.TerrainTexture2 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_2)
|
|
||||||
assetUuids[regionSettings.TerrainTexture2] = AssetType.Texture;
|
|
||||||
|
|
||||||
if (regionSettings.TerrainTexture3 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_3)
|
|
||||||
assetUuids[regionSettings.TerrainTexture3] = AssetType.Texture;
|
|
||||||
|
|
||||||
if (regionSettings.TerrainTexture4 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_4)
|
|
||||||
assetUuids[regionSettings.TerrainTexture4] = AssetType.Texture;
|
|
||||||
|
|
||||||
TarArchiveWriter archiveWriter = new TarArchiveWriter(m_saveStream);
|
|
||||||
|
|
||||||
// Asynchronously request all the assets required to perform this archive operation
|
|
||||||
ArchiveWriteRequestExecution awre
|
|
||||||
= new ArchiveWriteRequestExecution(
|
|
||||||
sceneObjects,
|
|
||||||
m_scene.RequestModuleInterface<ITerrainModule>(),
|
|
||||||
m_scene.RequestModuleInterface<IRegionSerialiserModule>(),
|
|
||||||
m_scene,
|
|
||||||
archiveWriter,
|
|
||||||
m_requestId,
|
|
||||||
options);
|
|
||||||
|
|
||||||
m_log.InfoFormat("[ARCHIVER]: Creating archive file. This may take some time.");
|
|
||||||
|
|
||||||
// Write out control file. This has to be done first so that subsequent loaders will see this file first
|
|
||||||
// XXX: I know this is a weak way of doing it since external non-OAR aware tar executables will not do this
|
|
||||||
archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile(options));
|
|
||||||
m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");
|
|
||||||
|
|
||||||
new AssetsRequest(
|
|
||||||
new AssetsArchiver(archiveWriter), assetUuids,
|
|
||||||
m_scene.AssetService, awre.ReceivedAllAssets).Execute();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create the control file for the most up to date archive
|
/// Create the control file for the most up to date archive
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static string Create0p2ControlFile(Dictionary<string, object> options)
|
public static string CreateControlFile(Dictionary<string, object> options)
|
||||||
{
|
{
|
||||||
int majorVersion = 0, minorVersion = 5;
|
int majorVersion = MAX_MAJOR_VERSION, minorVersion = 0;
|
||||||
|
|
||||||
if (options.ContainsKey("version"))
|
if (options.ContainsKey("version"))
|
||||||
{
|
{
|
||||||
minorVersion = 0;
|
|
||||||
string[] parts = options["version"].ToString().Split('.');
|
string[] parts = options["version"].ToString().Split('.');
|
||||||
if (parts.Length >= 1)
|
if (parts.Length >= 1)
|
||||||
majorVersion = Int32.Parse(parts[0]);
|
{
|
||||||
if (parts.Length >= 2)
|
majorVersion = Int32.Parse(parts[0]);
|
||||||
minorVersion = Int32.Parse(parts[1]);
|
|
||||||
|
if (parts.Length >= 2)
|
||||||
|
minorVersion = Int32.Parse(parts[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (majorVersion < MIN_MAJOR_VERSION || majorVersion > MAX_MAJOR_VERSION)
|
||||||
|
{
|
||||||
|
throw new Exception(
|
||||||
|
string.Format(
|
||||||
|
"OAR version number for save must be between {0} and {1}",
|
||||||
|
MIN_MAJOR_VERSION, MAX_MAJOR_VERSION));
|
||||||
|
}
|
||||||
|
else if (majorVersion == MAX_MAJOR_VERSION)
|
||||||
|
{
|
||||||
|
// Force 1.0
|
||||||
|
minorVersion = 0;
|
||||||
|
}
|
||||||
|
else if (majorVersion == MIN_MAJOR_VERSION)
|
||||||
|
{
|
||||||
|
// Force 0.4
|
||||||
|
minorVersion = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_log.InfoFormat("[ARCHIVER]: Creating version {0}.{1} OAR", majorVersion, minorVersion);
|
m_log.InfoFormat("[ARCHIVER]: Creating version {0}.{1} OAR", majorVersion, minorVersion);
|
||||||
// if (majorVersion == 1)
|
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");
|
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");
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
XmlTextWriter xtw = new XmlTextWriter(sw);
|
XmlTextWriter xtw = new XmlTextWriter(sw);
|
||||||
|
|
Loading…
Reference in New Issue