From 1bd4219078b48e0e69aca65908a127bc19ca5610 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Sat, 16 Oct 2010 03:52:11 +0100
Subject: save oar control file first rather than in the middle so that it's
the first thing we come accross on load
this exposes a weekness with using tar where we don't control the order in which files are loaded. can't be helped for now
---
.../World/Archiver/ArchiveWriteRequestExecution.cs | 37 +--------------------
.../Archiver/ArchiveWriteRequestPreparation.cs | 38 ++++++++++++++++++++++
.../World/Archiver/Tests/ArchiverTests.cs | 4 +--
3 files changed, 41 insertions(+), 38 deletions(-)
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs
index eb9688d..d1fe1f5 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs
@@ -108,12 +108,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver
// "[ARCHIVER]: Received {0} of {1} assets requested",
// assetsFoundUuids.Count, assetsFoundUuids.Count + assetsNotFoundUuids.Count);
- m_log.InfoFormat("[ARCHIVER]: Creating archive file. This may take some time.");
-
- // Write out control file
- m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile());
- m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");
-
// Write out region settings
string settingsPath
= String.Format("{0}{1}.xml", ArchiveConstants.SETTINGS_PATH, m_scene.RegionInfo.RegionName);
@@ -155,35 +149,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver
m_log.InfoFormat("[ARCHIVER]: Added scene objects to archive.");
}
- ///
- /// Create the control file for a 0.2 version archive
- ///
- ///
- public static string Create0p2ControlFile()
- {
- StringWriter sw = new StringWriter();
- XmlTextWriter xtw = new XmlTextWriter(sw);
- xtw.Formatting = Formatting.Indented;
- xtw.WriteStartDocument();
- xtw.WriteStartElement("archive");
- xtw.WriteAttributeString("major_version", "0");
- xtw.WriteAttributeString("minor_version", "3");
-
- xtw.WriteStartElement("creation_info");
- DateTime now = DateTime.UtcNow;
- TimeSpan t = now - new DateTime(1970, 1, 1);
- xtw.WriteElementString("datetime", ((int)t.TotalSeconds).ToString());
- xtw.WriteElementString("id", UUID.Random().ToString());
- xtw.WriteEndElement();
- xtw.WriteEndElement();
-
- xtw.Flush();
- xtw.Close();
-
- String s = sw.ToString();
- sw.Close();
-
- return s;
- }
+
}
}
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
index e9a476c..f867e50 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
@@ -32,6 +32,7 @@ using System.IO.Compression;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading;
+using System.Xml;
using log4net;
using OpenMetaverse;
using OpenSim.Framework;
@@ -167,10 +168,47 @@ namespace OpenSim.Region.CoreModules.World.Archiver
archiveWriter,
m_requestId,
options);
+
+ m_log.InfoFormat("[ARCHIVER]: Creating archive file. This may take some time.");
+
+ // Write out control file
+ archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile());
+ m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");
new AssetsRequest(
new AssetsArchiver(archiveWriter), assetUuids,
m_scene.AssetService, awre.ReceivedAllAssets).Execute();
}
+
+ ///
+ /// Create the control file for a 0.2 version archive
+ ///
+ ///
+ public static string Create0p2ControlFile()
+ {
+ StringWriter sw = new StringWriter();
+ XmlTextWriter xtw = new XmlTextWriter(sw);
+ xtw.Formatting = Formatting.Indented;
+ xtw.WriteStartDocument();
+ xtw.WriteStartElement("archive");
+ xtw.WriteAttributeString("major_version", "0");
+ xtw.WriteAttributeString("minor_version", "3");
+
+ xtw.WriteStartElement("creation_info");
+ DateTime now = DateTime.UtcNow;
+ TimeSpan t = now - new DateTime(1970, 1, 1);
+ xtw.WriteElementString("datetime", ((int)t.TotalSeconds).ToString());
+ xtw.WriteElementString("id", UUID.Random().ToString());
+ xtw.WriteEndElement();
+ xtw.WriteEndElement();
+
+ xtw.Flush();
+ xtw.Close();
+
+ String s = sw.ToString();
+ sw.Close();
+
+ return s;
+ }
}
}
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index 3342164..b72cd02 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -230,7 +230,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
// upset load
tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
- tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile());
+ tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.Create0p2ControlFile());
SceneObjectPart part1 = CreateSceneObjectPart1();
SceneObjectGroup object1 = new SceneObjectGroup(part1);
@@ -329,7 +329,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
tar.WriteDir(ArchiveConstants.TERRAINS_PATH);
- tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestExecution.Create0p2ControlFile());
+ tar.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, ArchiveWriteRequestPreparation.Create0p2ControlFile());
RegionSettings rs = new RegionSettings();
rs.AgentLimit = 17;
--
cgit v1.1