aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/Archiver
diff options
context:
space:
mode:
authorMelanie2010-04-19 07:00:40 +0100
committerMelanie2010-04-19 07:00:40 +0100
commit98cb4f74b265dfb8ca3eb8c8d3ad604249398df1 (patch)
tree1339d3707430a20662bdcd3eb4e9ef86abc6a4fd /OpenSim/Region/CoreModules/World/Archiver
parentMerge branch 'master' into careminster-presence-refactor (diff)
parentAll scripts are now created suspended and are only unsuspended when the object (diff)
downloadopensim-SC-98cb4f74b265dfb8ca3eb8c8d3ad604249398df1.zip
opensim-SC-98cb4f74b265dfb8ca3eb8c8d3ad604249398df1.tar.gz
opensim-SC-98cb4f74b265dfb8ca3eb8c8d3ad604249398df1.tar.bz2
opensim-SC-98cb4f74b265dfb8ca3eb8c8d3ad604249398df1.tar.xz
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Archiver')
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs46
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs19
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs2
3 files changed, 39 insertions, 28 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index 14bab6e..b37beab 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -53,25 +53,27 @@ namespace OpenSim.Region.CoreModules.World.Archiver
53 { 53 {
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 55
56 private static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding(); 56 protected Scene m_scene;
57 private static UTF8Encoding m_utf8Encoding = new UTF8Encoding(); 57 protected Stream m_loadStream;
58 58 protected Guid m_requestId;
59 private Scene m_scene; 59 protected string m_errorMessage;
60 private Stream m_loadStream;
61 private Guid m_requestId;
62 private string m_errorMessage;
63 60
64 /// <value> 61 /// <value>
65 /// Should the archive being loaded be merged with what is already on the region? 62 /// Should the archive being loaded be merged with what is already on the region?
66 /// </value> 63 /// </value>
67 private bool m_merge; 64 protected bool m_merge;
65
66 /// <value>
67 /// Should we ignore any assets when reloading the archive?
68 /// </value>
69 protected bool m_skipAssets;
68 70
69 /// <summary> 71 /// <summary>
70 /// Used to cache lookups for valid uuids. 72 /// Used to cache lookups for valid uuids.
71 /// </summary> 73 /// </summary>
72 private IDictionary<UUID, bool> m_validUserUuids = new Dictionary<UUID, bool>(); 74 private IDictionary<UUID, bool> m_validUserUuids = new Dictionary<UUID, bool>();
73 75
74 public ArchiveReadRequest(Scene scene, string loadPath, bool merge, Guid requestId) 76 public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, Guid requestId)
75 { 77 {
76 m_scene = scene; 78 m_scene = scene;
77 79
@@ -89,14 +91,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
89 91
90 m_errorMessage = String.Empty; 92 m_errorMessage = String.Empty;
91 m_merge = merge; 93 m_merge = merge;
94 m_skipAssets = skipAssets;
92 m_requestId = requestId; 95 m_requestId = requestId;
93 } 96 }
94 97
95 public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, Guid requestId) 98 public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, bool skipAssets, Guid requestId)
96 { 99 {
97 m_scene = scene; 100 m_scene = scene;
98 m_loadStream = loadStream; 101 m_loadStream = loadStream;
99 m_merge = merge; 102 m_merge = merge;
103 m_skipAssets = skipAssets;
100 m_requestId = requestId; 104 m_requestId = requestId;
101 } 105 }
102 106
@@ -133,9 +137,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver
133 137
134 if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH)) 138 if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH))
135 { 139 {
136 serialisedSceneObjects.Add(m_utf8Encoding.GetString(data)); 140 serialisedSceneObjects.Add(Encoding.UTF8.GetString(data));
137 } 141 }
138 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) 142 else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH) && !m_skipAssets)
139 { 143 {
140 if (LoadAsset(filePath, data)) 144 if (LoadAsset(filePath, data))
141 successfulAssetRestores++; 145 successfulAssetRestores++;
@@ -155,7 +159,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
155 } 159 }
156 else if (!m_merge && filePath.StartsWith(ArchiveConstants.LANDDATA_PATH)) 160 else if (!m_merge && filePath.StartsWith(ArchiveConstants.LANDDATA_PATH))
157 { 161 {
158 serialisedParcels.Add(m_utf8Encoding.GetString(data)); 162 serialisedParcels.Add(Encoding.UTF8.GetString(data));
159 } 163 }
160 else if (filePath == ArchiveConstants.CONTROL_FILE_PATH) 164 else if (filePath == ArchiveConstants.CONTROL_FILE_PATH)
161 { 165 {
@@ -178,12 +182,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver
178 archive.Close(); 182 archive.Close();
179 } 183 }
180 184
181 m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores); 185 if (!m_skipAssets)
182
183 if (failedAssetRestores > 0)
184 { 186 {
185 m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores); 187 m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores);
186 m_errorMessage += String.Format("Failed to load {0} assets", failedAssetRestores); 188
189 if (failedAssetRestores > 0)
190 {
191 m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores);
192 m_errorMessage += String.Format("Failed to load {0} assets", failedAssetRestores);
193 }
187 } 194 }
188 195
189 if (!m_merge) 196 if (!m_merge)
@@ -279,6 +286,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
279 { 286 {
280 sceneObjectsLoadedCount++; 287 sceneObjectsLoadedCount++;
281 sceneObject.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, 0); 288 sceneObject.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, 0);
289 sceneObject.ResumeScripts();
282 } 290 }
283 } 291 }
284 292
@@ -543,7 +551,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
543 XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None); 551 XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);
544 552
545 XmlTextReader xtr 553 XmlTextReader xtr
546 = new XmlTextReader(m_asciiEncoding.GetString(data), XmlNodeType.Document, context); 554 = new XmlTextReader(Encoding.ASCII.GetString(data), XmlNodeType.Document, context);
547 555
548 RegionSettings currentRegionSettings = m_scene.RegionInfo.RegionSettings; 556 RegionSettings currentRegionSettings = m_scene.RegionInfo.RegionSettings;
549 557
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
94 public void HandleLoadOarConsoleCommand(string module, string[] cmdparams) 94 public void HandleLoadOarConsoleCommand(string module, string[] cmdparams)
95 { 95 {
96 bool mergeOar = false; 96 bool mergeOar = false;
97 bool skipAssets = false;
97 98
98 OptionSet options = new OptionSet().Add("m|merge", delegate (string v) { mergeOar = v != null; }); 99 OptionSet options = new OptionSet().Add("m|merge", delegate (string v) { mergeOar = v != null; });
100 options.Add("s|skip-assets", delegate (string v) { skipAssets = v != null; });
101
99 List<string> mainParams = options.Parse(cmdparams); 102 List<string> mainParams = options.Parse(cmdparams);
100 103
101// m_log.DebugFormat("MERGE OAR IS [{0}]", mergeOar); 104// m_log.DebugFormat("MERGE OAR IS [{0}]", mergeOar);
@@ -105,11 +108,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
105 108
106 if (mainParams.Count > 2) 109 if (mainParams.Count > 2)
107 { 110 {
108 DearchiveRegion(mainParams[2], mergeOar, Guid.Empty); 111 DearchiveRegion(mainParams[2], mergeOar, skipAssets, Guid.Empty);
109 } 112 }
110 else 113 else
111 { 114 {
112 DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, mergeOar, Guid.Empty); 115 DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, mergeOar, skipAssets, Guid.Empty);
113 } 116 }
114 } 117 }
115 118
@@ -154,25 +157,25 @@ namespace OpenSim.Region.CoreModules.World.Archiver
154 157
155 public void DearchiveRegion(string loadPath) 158 public void DearchiveRegion(string loadPath)
156 { 159 {
157 DearchiveRegion(loadPath, false, Guid.Empty); 160 DearchiveRegion(loadPath, false, false, Guid.Empty);
158 } 161 }
159 162
160 public void DearchiveRegion(string loadPath, bool merge, Guid requestId) 163 public void DearchiveRegion(string loadPath, bool merge, bool skipAssets, Guid requestId)
161 { 164 {
162 m_log.InfoFormat( 165 m_log.InfoFormat(
163 "[ARCHIVER]: Loading archive to region {0} from {1}", m_scene.RegionInfo.RegionName, loadPath); 166 "[ARCHIVER]: Loading archive to region {0} from {1}", m_scene.RegionInfo.RegionName, loadPath);
164 167
165 new ArchiveReadRequest(m_scene, loadPath, merge, requestId).DearchiveRegion(); 168 new ArchiveReadRequest(m_scene, loadPath, merge, skipAssets, requestId).DearchiveRegion();
166 } 169 }
167 170
168 public void DearchiveRegion(Stream loadStream) 171 public void DearchiveRegion(Stream loadStream)
169 { 172 {
170 DearchiveRegion(loadStream, false, Guid.Empty); 173 DearchiveRegion(loadStream, false, false, Guid.Empty);
171 } 174 }
172 175
173 public void DearchiveRegion(Stream loadStream, bool merge, Guid requestId) 176 public void DearchiveRegion(Stream loadStream, bool merge, bool skipAssets, Guid requestId)
174 { 177 {
175 new ArchiveReadRequest(m_scene, loadStream, merge, requestId).DearchiveRegion(); 178 new ArchiveReadRequest(m_scene, loadStream, merge, skipAssets, requestId).DearchiveRegion();
176 } 179 }
177 } 180 }
178} 181}
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
442 byte[] archive = archiveWriteStream.ToArray(); 442 byte[] archive = archiveWriteStream.ToArray();
443 MemoryStream archiveReadStream = new MemoryStream(archive); 443 MemoryStream archiveReadStream = new MemoryStream(archive);
444 444
445 m_archiverModule.DearchiveRegion(archiveReadStream, true, Guid.Empty); 445 m_archiverModule.DearchiveRegion(archiveReadStream, true, false, Guid.Empty);
446 446
447 SceneObjectPart object1Existing = m_scene.GetSceneObjectPart(part1.Name); 447 SceneObjectPart object1Existing = m_scene.GetSceneObjectPart(part1.Name);
448 Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge"); 448 Assert.That(object1Existing, Is.Not.Null, "object1 was not present after merge");