From 88ead9ee63fe87b16d7c24b3a38bf6567f3166f6 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 24 Nov 2009 17:28:38 +0000
Subject: pass all command parameters to load/save oar, not just the filename
unfortunately, these commands cannot yet be properly relocated to the region
modules due to deficiencies in the region module infrastructure
---
.../CoreModules/World/Archiver/ArchiverModule.cs | 37 ++++++++++++++++++++++
1 file changed, 37 insertions(+)
(limited to 'OpenSim/Region/CoreModules/World/Archiver')
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
index 8d4f91b..181f4c6 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs
@@ -45,6 +45,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
private Scene m_scene;
+ ///
+ /// The file used to load and save an opensimulator archive if no filename has been specified
+ ///
+ protected const string DEFAULT_OAR_BACKUP_FILENAME = "region.oar";
+
public string Name
{
get { return "RegionArchiverModule"; }
@@ -80,6 +85,38 @@ namespace OpenSim.Region.CoreModules.World.Archiver
{
}
+ ///
+ /// Load a whole region from an opensimulator archive.
+ ///
+ ///
+ public void HandleLoadOarConsoleCommand(string module, string[] cmdparams)
+ {
+ if (cmdparams.Length > 2)
+ {
+ DearchiveRegion(cmdparams[2]);
+ }
+ else
+ {
+ DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME);
+ }
+ }
+
+ ///
+ /// Save a region to a file, including all the assets needed to restore it.
+ ///
+ ///
+ public void HandleSaveOarConsoleCommand(string module, string[] cmdparams)
+ {
+ if (cmdparams.Length > 2)
+ {
+ ArchiveRegion(cmdparams[2]);
+ }
+ else
+ {
+ ArchiveRegion(DEFAULT_OAR_BACKUP_FILENAME);
+ }
+ }
+
public void ArchiveRegion(string savePath)
{
ArchiveRegion(savePath, Guid.Empty);
--
cgit v1.1
From c083ab682425d13a7369e3f82c82ccbc3c65102a Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 24 Nov 2009 17:47:09 +0000
Subject: make save and load oar slightly more robust by always closing the
archive streams even if there has been an error
---
.../World/Archiver/ArchiveReadRequest.cs | 15 ++++++++-------
.../World/Archiver/ArchiveWriteRequestExecution.cs | 22 ++++++++++++++++------
.../Archiver/ArchiveWriteRequestPreparation.cs | 6 ++++++
3 files changed, 30 insertions(+), 13 deletions(-)
(limited to 'OpenSim/Region/CoreModules/World/Archiver')
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index 70a225e..34b81d8 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -103,14 +103,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver
List serialisedSceneObjects = new List();
List serialisedParcels = new List();
string filePath = "NONE";
+
+ TarArchiveReader archive = new TarArchiveReader(m_loadStream);
+ byte[] data;
+ TarArchiveReader.TarEntryType entryType;
try
{
- TarArchiveReader archive = new TarArchiveReader(m_loadStream);
-
- byte[] data;
- TarArchiveReader.TarEntryType entryType;
-
while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
{
//m_log.DebugFormat(
@@ -152,8 +151,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver
}
//m_log.Debug("[ARCHIVER]: Reached end of archive");
-
- archive.Close();
}
catch (Exception e)
{
@@ -163,6 +160,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver
m_scene.EventManager.TriggerOarFileLoaded(m_requestId, m_errorMessage);
return;
}
+ finally
+ {
+ archive.Close();
+ }
m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores);
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs
index f039be8..75c4557 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs
@@ -80,6 +80,22 @@ namespace OpenSim.Region.CoreModules.World.Archiver
protected internal void ReceivedAllAssets(
ICollection assetsFoundUuids, ICollection assetsNotFoundUuids)
{
+ try
+ {
+ Save(assetsFoundUuids, assetsNotFoundUuids);
+ }
+ finally
+ {
+ m_archiveWriter.Close();
+ }
+
+ m_log.InfoFormat("[ARCHIVER]: Finished writing out OAR for {0}", m_scene.RegionInfo.RegionName);
+
+ m_scene.EventManager.TriggerOarFileSaved(m_requestId, String.Empty);
+ }
+
+ protected internal void Save(ICollection assetsFoundUuids, ICollection assetsNotFoundUuids)
+ {
foreach (UUID uuid in assetsNotFoundUuids)
{
m_log.DebugFormat("[ARCHIVER]: Could not find asset {0}", uuid);
@@ -143,12 +159,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver
}
m_log.InfoFormat("[ARCHIVER]: Added scene objects to archive.");
-
- m_archiveWriter.Close();
-
- m_log.InfoFormat("[ARCHIVER]: Finished writing out OAR for {0}", m_scene.RegionInfo.RegionName);
-
- m_scene.EventManager.TriggerOarFileSaved(m_requestId, String.Empty);
}
///
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
index 9e4fbbe..f08d8ec 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
@@ -56,6 +56,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver
///
/// Constructor
///
+ ///
+ /// The path to which to save data.
+ /// The id associated with this request
+ ///
+ /// If there was a problem opening a stream for the file specified by the savePath
+ ///
public ArchiveWriteRequestPreparation(Scene scene, string savePath, Guid requestId)
{
m_scene = scene;
--
cgit v1.1