From bf3956aeb0a44d0dd455e330234fcf0e18f5ea43 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 16 Apr 2010 22:29:11 +0100
Subject: 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.
---
.../World/Archiver/ArchiveReadRequest.cs | 40 ++++++++++++++--------
.../CoreModules/World/Archiver/ArchiverModule.cs | 19 +++++-----
.../World/Archiver/Tests/ArchiverTests.cs | 2 +-
3 files changed, 37 insertions(+), 24 deletions(-)
(limited to 'OpenSim/Region/CoreModules')
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index b1b2336f8..cde7c93 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -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;
///
/// Should the archive being loaded be merged with what is already on the region?
///
- private bool m_merge;
+ protected bool m_merge;
+
+ ///
+ /// Should we ignore any assets when reloading the archive?
+ ///
+ protected bool m_skipAssets;
///
/// Used to cache lookups for valid uuids.
///
private IDictionary m_validUserUuids = new Dictionary();
- 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,12 +185,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver
archive.Close();
}
- m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores);
-
- if (failedAssetRestores > 0)
+ if (!m_skipAssets)
{
- m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores);
- m_errorMessage += String.Format("Failed to load {0} assets", failedAssetRestores);
+ m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores);
+
+ if (failedAssetRestores > 0)
+ {
+ m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores);
+ m_errorMessage += String.Format("Failed to load {0} assets", failedAssetRestores);
+ }
}
if (!m_merge)
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
index fc8d4e1..82ede01 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
@@ -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 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();
}
}
}
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index de16d89..624dc22 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -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");
--
cgit v1.1