Add --skip-assets option to load oar.
This allows you to load an oar without loading its assets. This is useful if you know that the required assets are already in the asset service, since loading without assets is quicker. This option will become more useful when the ability to save oars without assets is added, which should happen fairly soon. At this point there will also be better documentation.slimupdates
parent
cf46735856
commit
bf3956aeb0
|
@ -251,8 +251,9 @@ namespace OpenSim
|
|||
"Save named prim to XML2", SavePrimsXml2);
|
||||
|
||||
m_console.Commands.AddCommand("region", false, "load oar",
|
||||
"load oar [--merge] <oar name>",
|
||||
"Load a region's data from OAR archive", LoadOar);
|
||||
"load oar [--merge] [--skip-assets] <oar name>",
|
||||
"Load a region's data from OAR archive. --merge will merge the oar with the existing scene. --skip-assets will load the oar but ignore the assets it contains",
|
||||
LoadOar);
|
||||
|
||||
m_console.Commands.AddCommand("region", false, "save oar",
|
||||
"save oar <oar name>",
|
||||
|
|
|
@ -53,25 +53,30 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
|
||||
private static UTF8Encoding m_utf8Encoding = new UTF8Encoding();
|
||||
protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
|
||||
protected static UTF8Encoding m_utf8Encoding = new UTF8Encoding();
|
||||
|
||||
private Scene m_scene;
|
||||
private Stream m_loadStream;
|
||||
private Guid m_requestId;
|
||||
private string m_errorMessage;
|
||||
protected Scene m_scene;
|
||||
protected Stream m_loadStream;
|
||||
protected Guid m_requestId;
|
||||
protected string m_errorMessage;
|
||||
|
||||
/// <value>
|
||||
/// Should the archive being loaded be merged with what is already on the region?
|
||||
/// </value>
|
||||
private bool m_merge;
|
||||
protected bool m_merge;
|
||||
|
||||
/// <value>
|
||||
/// Should we ignore any assets when reloading the archive?
|
||||
/// </value>
|
||||
protected bool m_skipAssets;
|
||||
|
||||
/// <summary>
|
||||
/// Used to cache lookups for valid uuids.
|
||||
/// </summary>
|
||||
private IDictionary<UUID, bool> m_validUserUuids = new Dictionary<UUID, bool>();
|
||||
|
||||
public ArchiveReadRequest(Scene scene, string loadPath, bool merge, Guid requestId)
|
||||
public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, Guid requestId)
|
||||
{
|
||||
m_scene = scene;
|
||||
|
||||
|
@ -89,14 +94,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
|
||||
m_errorMessage = String.Empty;
|
||||
m_merge = merge;
|
||||
m_skipAssets = skipAssets;
|
||||
m_requestId = requestId;
|
||||
}
|
||||
|
||||
public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, Guid requestId)
|
||||
public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, bool skipAssets, Guid requestId)
|
||||
{
|
||||
m_scene = scene;
|
||||
m_loadStream = loadStream;
|
||||
m_merge = merge;
|
||||
m_skipAssets = skipAssets;
|
||||
m_requestId = requestId;
|
||||
}
|
||||
|
||||
|
@ -135,7 +142,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
{
|
||||
serialisedSceneObjects.Add(m_utf8Encoding.GetString(data));
|
||||
}
|
||||
else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
|
||||
else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH) && !m_skipAssets)
|
||||
{
|
||||
if (LoadAsset(filePath, data))
|
||||
successfulAssetRestores++;
|
||||
|
@ -178,6 +185,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
archive.Close();
|
||||
}
|
||||
|
||||
if (!m_skipAssets)
|
||||
{
|
||||
m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores);
|
||||
|
||||
if (failedAssetRestores > 0)
|
||||
|
@ -185,6 +194,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores);
|
||||
m_errorMessage += String.Format("Failed to load {0} assets", failedAssetRestores);
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_merge)
|
||||
{
|
||||
|
|
|
@ -94,8 +94,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
public void HandleLoadOarConsoleCommand(string module, string[] cmdparams)
|
||||
{
|
||||
bool mergeOar = false;
|
||||
bool skipAssets = false;
|
||||
|
||||
OptionSet options = new OptionSet().Add("m|merge", delegate (string v) { mergeOar = v != null; });
|
||||
options.Add("s|skip-assets", delegate (string v) { skipAssets = v != null; });
|
||||
|
||||
List<string> mainParams = options.Parse(cmdparams);
|
||||
|
||||
// m_log.DebugFormat("MERGE OAR IS [{0}]", mergeOar);
|
||||
|
@ -105,11 +108,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
|
||||
if (mainParams.Count > 2)
|
||||
{
|
||||
DearchiveRegion(mainParams[2], mergeOar, Guid.Empty);
|
||||
DearchiveRegion(mainParams[2], mergeOar, skipAssets, Guid.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, mergeOar, Guid.Empty);
|
||||
DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, mergeOar, skipAssets, Guid.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,25 +157,25 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
|
||||
public void DearchiveRegion(string loadPath)
|
||||
{
|
||||
DearchiveRegion(loadPath, false, Guid.Empty);
|
||||
DearchiveRegion(loadPath, false, false, Guid.Empty);
|
||||
}
|
||||
|
||||
public void DearchiveRegion(string loadPath, bool merge, Guid requestId)
|
||||
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);
|
||||
|
||||
new ArchiveReadRequest(m_scene, loadPath, merge, requestId).DearchiveRegion();
|
||||
new ArchiveReadRequest(m_scene, loadPath, merge, skipAssets, requestId).DearchiveRegion();
|
||||
}
|
||||
|
||||
public void DearchiveRegion(Stream loadStream)
|
||||
{
|
||||
DearchiveRegion(loadStream, false, Guid.Empty);
|
||||
DearchiveRegion(loadStream, false, false, Guid.Empty);
|
||||
}
|
||||
|
||||
public void DearchiveRegion(Stream loadStream, bool merge, Guid requestId)
|
||||
public void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Guid requestId)
|
||||
{
|
||||
new ArchiveReadRequest(m_scene, loadStream, merge, requestId).DearchiveRegion();
|
||||
new ArchiveReadRequest(m_scene, loadStream, merge, skipAssets, requestId).DearchiveRegion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -442,7 +442,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
|
|||
byte[] archive = archiveWriteStream.ToArray();
|
||||
MemoryStream archiveReadStream = new MemoryStream(archive);
|
||||
|
||||
m_archiverModule.DearchiveRegion(archiveReadStream, true, Guid.Empty);
|
||||
m_archiverModule.DearchiveRegion(archiveReadStream, true, false, Guid.Empty);
|
||||
|
||||
SceneObjectPart object1Existing = m_scene.GetSceneObjectPart(part1.Name);
|
||||
Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge");
|
||||
|
|
|
@ -90,8 +90,12 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
/// 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, Guid requestId);
|
||||
void DearchiveRegion(string loadPath, bool merge, bool skipAssets, Guid requestId);
|
||||
|
||||
/// <summary>
|
||||
/// Dearchive a region from a stream. This replaces the existing scene.
|
||||
|
@ -113,7 +117,11 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
/// 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, Guid requestId);
|
||||
void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Guid requestId);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue