diff options
author | Jonathan Freedman | 2010-10-17 18:45:25 -0400 |
---|---|---|
committer | Jonathan Freedman | 2010-10-17 18:45:25 -0400 |
commit | 4e4fb93fae6c13ca6c6ac521991c4e4969b0fe65 (patch) | |
tree | 79142f2364b658f52b63e3ae688a5521290e2a4f /OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs | |
parent | * more url / hg cleanup (diff) | |
parent | Merge branch 'master' of ssh://diva@opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-4e4fb93fae6c13ca6c6ac521991c4e4969b0fe65.zip opensim-SC_OLD-4e4fb93fae6c13ca6c6ac521991c4e4969b0fe65.tar.gz opensim-SC_OLD-4e4fb93fae6c13ca6c6ac521991c4e4969b0fe65.tar.bz2 opensim-SC_OLD-4e4fb93fae6c13ca6c6ac521991c4e4969b0fe65.tar.xz |
Merge branch 'master' of git://opensimulator.org/git/opensim
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs | 48 |
1 files changed, 10 insertions, 38 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs index 586d98e..c062833 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs | |||
@@ -60,6 +60,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
60 | protected Scene m_scene; | 60 | protected Scene m_scene; |
61 | protected TarArchiveWriter m_archiveWriter; | 61 | protected TarArchiveWriter m_archiveWriter; |
62 | protected Guid m_requestId; | 62 | protected Guid m_requestId; |
63 | protected Dictionary<string, object> m_options; | ||
63 | 64 | ||
64 | public ArchiveWriteRequestExecution( | 65 | public ArchiveWriteRequestExecution( |
65 | List<SceneObjectGroup> sceneObjects, | 66 | List<SceneObjectGroup> sceneObjects, |
@@ -67,7 +68,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
67 | IRegionSerialiserModule serialiser, | 68 | IRegionSerialiserModule serialiser, |
68 | Scene scene, | 69 | Scene scene, |
69 | TarArchiveWriter archiveWriter, | 70 | TarArchiveWriter archiveWriter, |
70 | Guid requestId) | 71 | Guid requestId, |
72 | Dictionary<string, object> options) | ||
71 | { | 73 | { |
72 | m_sceneObjects = sceneObjects; | 74 | m_sceneObjects = sceneObjects; |
73 | m_terrainModule = terrainModule; | 75 | m_terrainModule = terrainModule; |
@@ -75,6 +77,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
75 | m_scene = scene; | 77 | m_scene = scene; |
76 | m_archiveWriter = archiveWriter; | 78 | m_archiveWriter = archiveWriter; |
77 | m_requestId = requestId; | 79 | m_requestId = requestId; |
80 | m_options = options; | ||
78 | } | 81 | } |
79 | 82 | ||
80 | protected internal void ReceivedAllAssets( | 83 | protected internal void ReceivedAllAssets( |
@@ -105,12 +108,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
105 | // "[ARCHIVER]: Received {0} of {1} assets requested", | 108 | // "[ARCHIVER]: Received {0} of {1} assets requested", |
106 | // assetsFoundUuids.Count, assetsFoundUuids.Count + assetsNotFoundUuids.Count); | 109 | // assetsFoundUuids.Count, assetsFoundUuids.Count + assetsNotFoundUuids.Count); |
107 | 110 | ||
108 | m_log.InfoFormat("[ARCHIVER]: Creating archive file. This may take some time."); | ||
109 | |||
110 | // Write out control file | ||
111 | m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p2ControlFile()); | ||
112 | m_log.InfoFormat("[ARCHIVER]: Added control file to archive."); | ||
113 | |||
114 | // Write out region settings | 111 | // Write out region settings |
115 | string settingsPath | 112 | string settingsPath |
116 | = String.Format("{0}{1}.xml", ArchiveConstants.SETTINGS_PATH, m_scene.RegionInfo.RegionName); | 113 | = String.Format("{0}{1}.xml", ArchiveConstants.SETTINGS_PATH, m_scene.RegionInfo.RegionName); |
@@ -140,47 +137,22 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
140 | 137 | ||
141 | m_log.InfoFormat("[ARCHIVER]: Added terrain information to archive."); | 138 | m_log.InfoFormat("[ARCHIVER]: Added terrain information to archive."); |
142 | 139 | ||
140 | Dictionary<string, object> serializationOptions = new Dictionary<string, object>(); | ||
141 | // if (m_options.ContainsKey("version") && (string)m_options["version"] == "0") | ||
142 | // serializationOptions["old-guids"] = true; | ||
143 | |||
143 | // Write out scene object metadata | 144 | // Write out scene object metadata |
144 | foreach (SceneObjectGroup sceneObject in m_sceneObjects) | 145 | foreach (SceneObjectGroup sceneObject in m_sceneObjects) |
145 | { | 146 | { |
146 | //m_log.DebugFormat("[ARCHIVER]: Saving {0} {1}, {2}", entity.Name, entity.UUID, entity.GetType()); | 147 | //m_log.DebugFormat("[ARCHIVER]: Saving {0} {1}, {2}", entity.Name, entity.UUID, entity.GetType()); |
147 | 148 | ||
148 | string serializedObject = m_serialiser.SerializeGroupToXml2(sceneObject); | 149 | string serializedObject = m_serialiser.SerializeGroupToXml2(sceneObject, serializationOptions); |
149 | m_archiveWriter.WriteFile(ArchiveHelpers.CreateObjectPath(sceneObject), serializedObject); | 150 | m_archiveWriter.WriteFile(ArchiveHelpers.CreateObjectPath(sceneObject), serializedObject); |
150 | } | 151 | } |
151 | 152 | ||
152 | m_log.InfoFormat("[ARCHIVER]: Added scene objects to archive."); | 153 | m_log.InfoFormat("[ARCHIVER]: Added scene objects to archive."); |
153 | } | 154 | } |
154 | 155 | ||
155 | /// <summary> | 156 | |
156 | /// Create the control file for a 0.2 version archive | ||
157 | /// </summary> | ||
158 | /// <returns></returns> | ||
159 | public static string Create0p2ControlFile() | ||
160 | { | ||
161 | StringWriter sw = new StringWriter(); | ||
162 | XmlTextWriter xtw = new XmlTextWriter(sw); | ||
163 | xtw.Formatting = Formatting.Indented; | ||
164 | xtw.WriteStartDocument(); | ||
165 | xtw.WriteStartElement("archive"); | ||
166 | xtw.WriteAttributeString("major_version", "0"); | ||
167 | xtw.WriteAttributeString("minor_version", "3"); | ||
168 | |||
169 | xtw.WriteStartElement("creation_info"); | ||
170 | DateTime now = DateTime.UtcNow; | ||
171 | TimeSpan t = now - new DateTime(1970, 1, 1); | ||
172 | xtw.WriteElementString("datetime", ((int)t.TotalSeconds).ToString()); | ||
173 | xtw.WriteElementString("id", UUID.Random().ToString()); | ||
174 | xtw.WriteEndElement(); | ||
175 | xtw.WriteEndElement(); | ||
176 | |||
177 | xtw.Flush(); | ||
178 | xtw.Close(); | ||
179 | |||
180 | String s = sw.ToString(); | ||
181 | sw.Close(); | ||
182 | |||
183 | return s; | ||
184 | } | ||
185 | } | 157 | } |
186 | } | 158 | } |