varregion: add --noterrain and --noparcel to 'load oar'.

--noterrain suppresses the loading of the terrain from the oar.
--noparcels suppresses the loading of parcel information from the oar.
varregion
Robert Adams 2014-01-19 11:03:08 -08:00
parent dd6db72939
commit 6fbfb47b92
6 changed files with 70 additions and 46 deletions

View File

@ -1484,9 +1484,11 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
IRegionArchiverModule archiver = scene.RequestModuleInterface<IRegionArchiverModule>();
Vector3 displacement = new Vector3(0f, 0f, 0f);
Dictionary<string, object> archiveOptions = new Dictionary<string,object>();
if (mergeOar) archiveOptions.Add("merge", null);
if (skipAssets) archiveOptions.Add("skipAssets", null);
if (archiver != null)
archiver.DearchiveRegion(filename, mergeOar, skipAssets, displacement, Guid.Empty);
archiver.DearchiveRegion(filename, Guid.Empty, archiveOptions);
else
throw new Exception("Archiver module not present for scene");

View File

@ -266,11 +266,13 @@ namespace OpenSim
SavePrimsXml2);
m_console.Commands.AddCommand("Archiving", false, "load oar",
"load oar [--merge] [--skip-assets] [--displacement \"<x,y,z>\"] [<OAR path>]",
"load oar [--merge] [--skip-assets] [--noterrain] [--displacement \"<x,y,z>\"] [<OAR path>]",
"Load a region's data from an OAR archive.",
"--merge will merge the OAR with the existing scene." + Environment.NewLine
+ "--skip-assets will load the OAR but ignore the assets it contains." + Environment.NewLine
+ "--displacement will add this value to the position of every object loaded" + Environment.NewLine
+ "--noterrain suppresses the loading of terrain from the oar" + Environment.NewLine
+ "--noparcels suppresses the loading of parcels from the oar" + Environment.NewLine
+ "The path can be either a filesystem location or a URI."
+ " If this is not given then the command looks for an OAR named region.oar in the current directory.",
LoadOar);

View File

@ -99,6 +99,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
/// </value>
protected bool m_merge;
/// <value>
/// If true, suppresses the loading of terrain from the oar file
/// </value>
protected bool m_noTerrain;
/// <value>
/// If true, suppresses the loading of parcels from the oar file
/// </value>
protected bool m_noParcels;
/// <value>
/// Should we ignore any assets when reloading the archive?
/// </value>
@ -107,7 +117,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
/// <value>
/// Displacement added to each object as it is added to the world
/// </value>
protected Vector3 m_displacement = new Vector3(0f, 0f, 0f);
protected Vector3 m_displacement = Vector3.Zero;
/// <summary>
/// Used to cache lookups for valid uuids.
@ -137,7 +147,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
private IAssetService m_assetService = null;
public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, Vector3 displacement, Guid requestId)
public ArchiveReadRequest(Scene scene, string loadPath, Guid requestId, Dictionary<string,object>options)
{
m_rootScene = scene;
@ -155,10 +165,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver
}
m_errorMessage = String.Empty;
m_merge = merge;
m_skipAssets = skipAssets;
m_merge = options.ContainsKey("merge");
m_noTerrain = options.ContainsKey("noTerrain");
m_noParcels = options.ContainsKey("noParcels");
m_skipAssets = options.ContainsKey("skipAssets");
m_requestId = requestId;
m_displacement = displacement;
m_displacement = options.ContainsKey("displacement") ? (Vector3)options["displacement"] : Vector3.Zero;
// Zero can never be a valid user id
m_validUserUuids[UUID.Zero] = false;
@ -167,13 +179,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver
m_assetService = m_rootScene.AssetService;
}
public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, bool skipAssets, Guid requestId)
public ArchiveReadRequest(Scene scene, Stream loadStream, Guid requestId, Dictionary<string, object>options)
{
m_rootScene = scene;
m_loadPath = null;
m_loadStream = loadStream;
m_merge = merge;
m_skipAssets = skipAssets;
m_skipAssets = options.ContainsKey("skipAssets");
m_merge = options.ContainsKey("merge");
m_requestId = requestId;
// Zero can never be a valid user id
@ -249,7 +261,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
if ((successfulAssetRestores + failedAssetRestores) % 250 == 0)
m_log.Debug("[ARCHIVER]: Loaded " + successfulAssetRestores + " assets and failed to load " + failedAssetRestores + " assets...");
}
else if (!m_merge && filePath.StartsWith(ArchiveConstants.TERRAINS_PATH))
else if (!m_noTerrain && !m_merge && filePath.StartsWith(ArchiveConstants.TERRAINS_PATH))
{
LoadTerrain(scene, filePath, data);
}
@ -257,7 +269,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
{
LoadRegionSettings(scene, filePath, data, dearchivedScenes);
}
else if (!m_merge && filePath.StartsWith(ArchiveConstants.LANDDATA_PATH))
else if (!m_noParcels && !m_merge && filePath.StartsWith(ArchiveConstants.LANDDATA_PATH))
{
sceneContext.SerialisedParcels.Add(Encoding.UTF8.GetString(data));
}

View File

@ -104,11 +104,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver
{
bool mergeOar = false;
bool skipAssets = false;
bool noTerrain = false;
bool noParcels = false;
Vector3 displacement = new Vector3(0f, 0f, 0f);
OptionSet options = new OptionSet();
options.Add("m|merge", delegate (string v) { mergeOar = (v != null); });
options.Add("s|skip-assets", delegate (string v) { skipAssets = (v != null); });
options.Add("noterrain", delegate (string v) { noTerrain = (v != null); });
options.Add("noparcels", delegate (string v) { noParcels = (v != null); });
options.Add("displacement=", delegate (string v) {
try
{
@ -138,13 +142,20 @@ namespace OpenSim.Region.CoreModules.World.Archiver
// foreach (string param in mainParams)
// m_log.DebugFormat("GOT PARAM [{0}]", param);
Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
if (mergeOar) archiveOptions.Add("merge", null);
if (skipAssets) archiveOptions.Add("skipAssets", null);
if (noTerrain) archiveOptions.Add("noTerrain", null);
if (noParcels) archiveOptions.Add("noParcels", null);
if (displacement != Vector3.Zero) archiveOptions.Add("displacement", displacement);
if (mainParams.Count > 2)
{
DearchiveRegion(mainParams[2], mergeOar, skipAssets, displacement, Guid.Empty);
DearchiveRegion(mainParams[2], Guid.Empty, archiveOptions);
}
else
{
DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, mergeOar, skipAssets, displacement, Guid.Empty);
DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, Guid.Empty, archiveOptions);
}
}
@ -214,25 +225,27 @@ namespace OpenSim.Region.CoreModules.World.Archiver
public void DearchiveRegion(string loadPath)
{
DearchiveRegion(loadPath, false, false, new Vector3(0f, 0f, 0f), Guid.Empty);
Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
DearchiveRegion(loadPath, Guid.Empty, archiveOptions);
}
public void DearchiveRegion(string loadPath, bool merge, bool skipAssets, Vector3 displacement, Guid requestId)
public void DearchiveRegion(string loadPath, Guid requestId, Dictionary<string,object> options)
{
m_log.InfoFormat(
"[ARCHIVER]: Loading archive to region {0} from {1}", Scene.RegionInfo.RegionName, loadPath);
new ArchiveReadRequest(Scene, loadPath, merge, skipAssets, displacement, requestId).DearchiveRegion();
new ArchiveReadRequest(Scene, loadPath, requestId, options).DearchiveRegion();
}
public void DearchiveRegion(Stream loadStream)
{
DearchiveRegion(loadStream, false, false, new Vector3(0f, 0f, 0f), Guid.Empty);
Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
DearchiveRegion(loadStream, Guid.Empty, archiveOptions);
}
public void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Vector3 displacement, Guid requestId)
public void DearchiveRegion(Stream loadStream, Guid requestId, Dictionary<string, object> options)
{
new ArchiveReadRequest(Scene, loadStream, merge, skipAssets, requestId).DearchiveRegion();
new ArchiveReadRequest(Scene, loadStream, requestId, options).DearchiveRegion();
}
}
}

View File

@ -225,7 +225,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
byte[] data = tar.ReadEntry(out filePath, out tarEntryType);
Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH));
ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, false, false, Guid.Empty);
Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, Guid.Empty, archiveOptions);
arr.LoadControlFile(filePath, data, new DearchiveScenesInfo());
Assert.That(arr.ControlFileLoaded, Is.True);
@ -309,7 +310,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
byte[] data = tar.ReadEntry(out filePath, out tarEntryType);
Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH));
ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, false, false, Guid.Empty);
Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, Guid.Empty, archiveOptions);
arr.LoadControlFile(filePath, data, new DearchiveScenesInfo());
Assert.That(arr.ControlFileLoaded, Is.True);
@ -752,7 +754,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
byte[] archive = archiveWriteStream.ToArray();
MemoryStream archiveReadStream = new MemoryStream(archive);
m_archiverModule.DearchiveRegion(archiveReadStream, true, false, new Vector3(0f, 0f, 0f), Guid.Empty);
Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
archiveOptions.Add("merge", null);
m_archiverModule.DearchiveRegion(archiveReadStream, Guid.Empty, archiveOptions);
SceneObjectPart object1Existing = m_scene.GetSceneObjectPart(part1.Name);
Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge");
@ -860,7 +864,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
byte[] data = tar.ReadEntry(out filePath, out tarEntryType);
Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH));
ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, false, false, Guid.Empty);
Dictionary<string, object> archiveOptions = new Dictionary<string, object>();
ArchiveReadRequest arr = new ArchiveReadRequest(m_scene, (Stream)null, Guid.Empty, archiveOptions);
arr.LoadControlFile(filePath, data, new DearchiveScenesInfo());
Assert.That(arr.ControlFileLoaded, Is.True);

View File

@ -102,16 +102,11 @@ namespace OpenSim.Region.Framework.Interfaces
/// If you want notification of when it has completed then subscribe to the EventManager.OnOarFileLoaded event.
///
/// <param name="loadPath"></param>
/// <param name="merge">
/// If true, the loaded region merges with the existing one rather than replacing it. Any terrain or region
/// settings in the archive will be ignored.
/// </param>
/// <param name="skipAssets">
/// If true, the archive is loaded without loading any assets contained within it. This is useful if the
/// assets are already known to be present in the grid's asset service.
/// </param>
/// <param name="requestId">If supplied, this request Id is later returned in the saved event</param>
void DearchiveRegion(string loadPath, bool merge, bool skipAssets, Vector3 displacement, Guid requestId);
/// <param name="options">
/// Dictionary of options.
/// </param>
void DearchiveRegion(string loadPath, Guid requestId, Dictionary<string,object> options);
/// <summary>
/// Dearchive a region from a stream. This replaces the existing scene.
@ -129,15 +124,10 @@ namespace OpenSim.Region.Framework.Interfaces
/// If you want notification of when it has completed then subscribe to the EventManager.OnOarFileLoaded event.
///
/// <param name="loadStream"></param>
/// <param name="merge">
/// If true, the loaded region merges with the existing one rather than replacing it. Any terrain or region
/// settings in the archive will be ignored.
/// </param>
/// <param name="skipAssets">
/// If true, the archive is loaded without loading any assets contained within it. This is useful if the
/// assets are already known to be present in the grid's asset service.
/// </param
/// <param name="requestId">If supplied, this request Id is later returned in the saved event</param>
void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Vector3 displacement, Guid requestId);
/// <param name="options">
/// Dictionary of options.
/// </param>
void DearchiveRegion(Stream loadStream, Guid requestId, Dictionary<string,object> options);
}
}