diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs | 65 |
1 files changed, 63 insertions, 2 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs index 283b33b..43789af 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; | |||
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using System.Text.RegularExpressions; | 33 | using System.Text.RegularExpressions; |
34 | using System.Threading; | 34 | using System.Threading; |
35 | using System.Xml; | ||
35 | using log4net; | 36 | using log4net; |
36 | using OpenMetaverse; | 37 | using OpenMetaverse; |
37 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
@@ -98,7 +99,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
98 | /// Archive the region requested. | 99 | /// Archive the region requested. |
99 | /// </summary> | 100 | /// </summary> |
100 | /// <exception cref="System.IO.IOException">if there was an io problem with creating the file</exception> | 101 | /// <exception cref="System.IO.IOException">if there was an io problem with creating the file</exception> |
101 | public void ArchiveRegion() | 102 | public void ArchiveRegion(Dictionary<string, object> options) |
102 | { | 103 | { |
103 | Dictionary<UUID, AssetType> assetUuids = new Dictionary<UUID, AssetType>(); | 104 | Dictionary<UUID, AssetType> assetUuids = new Dictionary<UUID, AssetType>(); |
104 | 105 | ||
@@ -165,11 +166,71 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
165 | m_scene.RequestModuleInterface<IRegionSerialiserModule>(), | 166 | m_scene.RequestModuleInterface<IRegionSerialiserModule>(), |
166 | m_scene, | 167 | m_scene, |
167 | archiveWriter, | 168 | archiveWriter, |
168 | m_requestId); | 169 | m_requestId, |
170 | options); | ||
171 | |||
172 | m_log.InfoFormat("[ARCHIVER]: Creating archive file. This may take some time."); | ||
173 | |||
174 | // Write out control file | ||
175 | archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile(options)); | ||
176 | m_log.InfoFormat("[ARCHIVER]: Added control file to archive."); | ||
169 | 177 | ||
170 | new AssetsRequest( | 178 | new AssetsRequest( |
171 | new AssetsArchiver(archiveWriter), assetUuids, | 179 | new AssetsArchiver(archiveWriter), assetUuids, |
172 | m_scene.AssetService, awre.ReceivedAllAssets).Execute(); | 180 | m_scene.AssetService, awre.ReceivedAllAssets).Execute(); |
173 | } | 181 | } |
182 | |||
183 | /// <summary> | ||
184 | /// Create the control file for the most up to date archive | ||
185 | /// </summary> | ||
186 | /// <returns></returns> | ||
187 | public static string Create0p2ControlFile(Dictionary<string, object> options) | ||
188 | { | ||
189 | int majorVersion = 0, minorVersion = 4; | ||
190 | |||
191 | /* | ||
192 | if (options.ContainsKey("version") && (string)options["version"] == "0") | ||
193 | { | ||
194 | majorVersion = 0; | ||
195 | minorVersion = 3; | ||
196 | } | ||
197 | else | ||
198 | { | ||
199 | majorVersion = 1; | ||
200 | minorVersion = 0; | ||
201 | } | ||
202 | */ | ||
203 | |||
204 | m_log.InfoFormat("[ARCHIVER]: Creating version {0}.{1} OAR", majorVersion, minorVersion); | ||
205 | // if (majorVersion == 1) | ||
206 | // { | ||
207 | // m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR"); | ||
208 | // } | ||
209 | |||
210 | |||
211 | StringWriter sw = new StringWriter(); | ||
212 | XmlTextWriter xtw = new XmlTextWriter(sw); | ||
213 | xtw.Formatting = Formatting.Indented; | ||
214 | xtw.WriteStartDocument(); | ||
215 | xtw.WriteStartElement("archive"); | ||
216 | xtw.WriteAttributeString("major_version", majorVersion.ToString()); | ||
217 | xtw.WriteAttributeString("minor_version", minorVersion.ToString()); | ||
218 | |||
219 | xtw.WriteStartElement("creation_info"); | ||
220 | DateTime now = DateTime.UtcNow; | ||
221 | TimeSpan t = now - new DateTime(1970, 1, 1); | ||
222 | xtw.WriteElementString("datetime", ((int)t.TotalSeconds).ToString()); | ||
223 | xtw.WriteElementString("id", UUID.Random().ToString()); | ||
224 | xtw.WriteEndElement(); | ||
225 | xtw.WriteEndElement(); | ||
226 | |||
227 | xtw.Flush(); | ||
228 | xtw.Close(); | ||
229 | |||
230 | String s = sw.ToString(); | ||
231 | sw.Close(); | ||
232 | |||
233 | return s; | ||
234 | } | ||
174 | } | 235 | } |
175 | } | 236 | } |