aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
diff options
context:
space:
mode:
authorJeff Ames2008-08-18 00:39:10 +0000
committerJeff Ames2008-08-18 00:39:10 +0000
commit6ef9d4da901a346c232458317cca6268da888e2e (patch)
treedd1d935b10f34f261839da9f9879c02322e8ede7 /OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
parentUpdate svn properties, minor formatting cleanup. (diff)
downloadopensim-SC-6ef9d4da901a346c232458317cca6268da888e2e.zip
opensim-SC-6ef9d4da901a346c232458317cca6268da888e2e.tar.gz
opensim-SC-6ef9d4da901a346c232458317cca6268da888e2e.tar.bz2
opensim-SC-6ef9d4da901a346c232458317cca6268da888e2e.tar.xz
Formatting cleanup.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs86
1 files changed, 43 insertions, 43 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
index 1340f8b..87106fb 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
@@ -53,7 +53,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
53 53
54 private Scene m_scene; 54 private Scene m_scene;
55 private string m_loadPath; 55 private string m_loadPath;
56 56
57 /// <summary> 57 /// <summary>
58 /// Used to cache lookups for valid uuids. 58 /// Used to cache lookups for valid uuids.
59 /// </summary> 59 /// </summary>
@@ -68,15 +68,15 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
68 } 68 }
69 69
70 private void DearchiveRegion() 70 private void DearchiveRegion()
71 { 71 {
72 TarArchiveReader archive 72 TarArchiveReader archive
73 = new TarArchiveReader( 73 = new TarArchiveReader(
74 new GZipStream(new FileStream(m_loadPath, FileMode.Open), CompressionMode.Decompress)); 74 new GZipStream(new FileStream(m_loadPath, FileMode.Open), CompressionMode.Decompress));
75 //AssetsDearchiver dearchiver = new AssetsDearchiver(m_scene.AssetCache); 75 //AssetsDearchiver dearchiver = new AssetsDearchiver(m_scene.AssetCache);
76 76
77 List<string> serialisedSceneObjects = new List<string>(); 77 List<string> serialisedSceneObjects = new List<string>();
78 string filePath = "ERROR"; 78 string filePath = "ERROR";
79 79
80 int successfulAssetRestores = 0; 80 int successfulAssetRestores = 0;
81 int failedAssetRestores = 0; 81 int failedAssetRestores = 0;
82 82
@@ -111,30 +111,30 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
111 //m_log.Debug("[ARCHIVER]: Reached end of archive"); 111 //m_log.Debug("[ARCHIVER]: Reached end of archive");
112 112
113 archive.Close(); 113 archive.Close();
114 114
115 m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores); 115 m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores);
116 116
117 if (failedAssetRestores > 0) 117 if (failedAssetRestores > 0)
118 m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores); 118 m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores);
119 119
120 m_log.Info("[ARCHIVER]: Clearing all existing scene objects"); 120 m_log.Info("[ARCHIVER]: Clearing all existing scene objects");
121 m_scene.DeleteAllSceneObjects(); 121 m_scene.DeleteAllSceneObjects();
122 122
123 // Reload serialized prims 123 // Reload serialized prims
124 m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects. Please wait.", serialisedSceneObjects.Count); 124 m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects. Please wait.", serialisedSceneObjects.Count);
125 125
126 IRegionSerialiser serialiser = m_scene.RequestModuleInterface<IRegionSerialiser>(); 126 IRegionSerialiser serialiser = m_scene.RequestModuleInterface<IRegionSerialiser>();
127 ICollection<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>(); 127 ICollection<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
128 128
129 foreach (string serialisedSceneObject in serialisedSceneObjects) 129 foreach (string serialisedSceneObject in serialisedSceneObjects)
130 { 130 {
131 SceneObjectGroup sceneObject = serialiser.DeserializeGroupFromXml2(serialisedSceneObject); 131 SceneObjectGroup sceneObject = serialiser.DeserializeGroupFromXml2(serialisedSceneObject);
132 132
133 // For now, give all incoming scene objects new uuids. This will allow scenes to be cloned 133 // For now, give all incoming scene objects new uuids. This will allow scenes to be cloned
134 // on the same region server and multiple examples a single object archive to be imported 134 // on the same region server and multiple examples a single object archive to be imported
135 // to the same scene (when this is possible). 135 // to the same scene (when this is possible).
136 sceneObject.ResetIDs(); 136 sceneObject.ResetIDs();
137 137
138 // Try to retain the original creator/owner/lastowner if their uuid is present on this grid 138 // Try to retain the original creator/owner/lastowner if their uuid is present on this grid
139 // otherwise, use the master avatar uuid instead 139 // otherwise, use the master avatar uuid instead
140 LLUUID masterAvatarId = m_scene.RegionInfo.MasterAvatarAssignedUUID; 140 LLUUID masterAvatarId = m_scene.RegionInfo.MasterAvatarAssignedUUID;
@@ -144,41 +144,41 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
144 { 144 {
145 if (!resolveUserUuid(part.CreatorID)) 145 if (!resolveUserUuid(part.CreatorID))
146 part.CreatorID = masterAvatarId; 146 part.CreatorID = masterAvatarId;
147 147
148 if (!resolveUserUuid(part.OwnerID)) 148 if (!resolveUserUuid(part.OwnerID))
149 part.OwnerID = masterAvatarId; 149 part.OwnerID = masterAvatarId;
150 150
151 if (!resolveUserUuid(part.LastOwnerID)) 151 if (!resolveUserUuid(part.LastOwnerID))
152 part.LastOwnerID = masterAvatarId; 152 part.LastOwnerID = masterAvatarId;
153 153
154 // And zap any troublesome sit target information 154 // And zap any troublesome sit target information
155 part.SitTargetOrientation = new Quaternion(0,0,0,1); 155 part.SitTargetOrientation = new Quaternion(0,0,0,1);
156 part.SitTargetPosition = new Vector3(0,0,0); 156 part.SitTargetPosition = new Vector3(0,0,0);
157 } 157 }
158 158
159 if (m_scene.AddRestoredSceneObject(sceneObject, true, false)) 159 if (m_scene.AddRestoredSceneObject(sceneObject, true, false))
160 { 160 {
161 sceneObjects.Add(sceneObject); 161 sceneObjects.Add(sceneObject);
162 } 162 }
163 } 163 }
164 164
165 m_log.InfoFormat("[ARCHIVER]: Restored {0} scene objects to the scene", sceneObjects.Count); 165 m_log.InfoFormat("[ARCHIVER]: Restored {0} scene objects to the scene", sceneObjects.Count);
166 166
167 int ignoredObjects = serialisedSceneObjects.Count - sceneObjects.Count; 167 int ignoredObjects = serialisedSceneObjects.Count - sceneObjects.Count;
168 168
169 if (ignoredObjects > 0) 169 if (ignoredObjects > 0)
170 m_log.WarnFormat("[ARCHIVER]: Ignored {0} scene objects that already existed in the scene", ignoredObjects); 170 m_log.WarnFormat("[ARCHIVER]: Ignored {0} scene objects that already existed in the scene", ignoredObjects);
171 171
172 m_log.InfoFormat("[ARCHIVER]: Successfully loaded archive"); 172 m_log.InfoFormat("[ARCHIVER]: Successfully loaded archive");
173 173
174 m_log.Debug("[ARCHIVER]: Starting scripts"); 174 m_log.Debug("[ARCHIVER]: Starting scripts");
175 175
176 foreach (SceneObjectGroup sceneObject in sceneObjects) 176 foreach (SceneObjectGroup sceneObject in sceneObjects)
177 { 177 {
178 sceneObject.CreateScriptInstances(0, true); 178 sceneObject.CreateScriptInstances(0, true);
179 } 179 }
180 } 180 }
181 181
182 /// <summary> 182 /// <summary>
183 /// Look up the given user id to check whether it's one that is valid for this grid. 183 /// Look up the given user id to check whether it's one that is valid for this grid.
184 /// </summary> 184 /// </summary>
@@ -194,13 +194,13 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
194 else 194 else
195 m_validUserUuids.Add(uuid, false); 195 m_validUserUuids.Add(uuid, false);
196 } 196 }
197 197
198 if (m_validUserUuids[uuid]) 198 if (m_validUserUuids[uuid])
199 return true; 199 return true;
200 else 200 else
201 return false; 201 return false;
202 } 202 }
203 203
204 /// <summary> 204 /// <summary>
205 /// Load an asset 205 /// Load an asset
206 /// </summary> 206 /// </summary>
@@ -212,20 +212,20 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
212 // Right now we're nastily obtaining the lluuid from the filename 212 // Right now we're nastily obtaining the lluuid from the filename
213 string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length); 213 string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length);
214 string extension = filename.Substring(filename.LastIndexOf("_")); 214 string extension = filename.Substring(filename.LastIndexOf("_"));
215 string uuid = filename.Remove(filename.Length - extension.Length); 215 string uuid = filename.Remove(filename.Length - extension.Length);
216 216
217 if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension)) 217 if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension))
218 { 218 {
219 sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; 219 sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];
220 220
221 //m_log.DebugFormat("[ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType); 221 //m_log.DebugFormat("[ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType);
222 222
223 AssetBase asset = new AssetBase(new LLUUID(uuid), String.Empty); 223 AssetBase asset = new AssetBase(new LLUUID(uuid), String.Empty);
224 asset.Type = assetType; 224 asset.Type = assetType;
225 asset.Data = data; 225 asset.Data = data;
226 226
227 m_scene.AssetCache.AddAsset(asset); 227 m_scene.AssetCache.AddAsset(asset);
228 228
229 return true; 229 return true;
230 } 230 }
231 else 231 else
@@ -233,11 +233,11 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
233 m_log.ErrorFormat( 233 m_log.ErrorFormat(
234 "[ARCHIVER]: Tried to dearchive data with path {0} with an unknown type extension {1}", 234 "[ARCHIVER]: Tried to dearchive data with path {0} with an unknown type extension {1}",
235 assetPath, extension); 235 assetPath, extension);
236 236
237 return false; 237 return false;
238 } 238 }
239 } 239 }
240 240
241 /// <summary> 241 /// <summary>
242 /// Load terrain data 242 /// Load terrain data
243 /// </summary> 243 /// </summary>
@@ -249,13 +249,13 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
249 private bool LoadTerrain(string terrainPath, byte[] data) 249 private bool LoadTerrain(string terrainPath, byte[] data)
250 { 250 {
251 ITerrainModule terrainModule = m_scene.RequestModuleInterface<ITerrainModule>(); 251 ITerrainModule terrainModule = m_scene.RequestModuleInterface<ITerrainModule>();
252 252
253 MemoryStream ms = new MemoryStream(data); 253 MemoryStream ms = new MemoryStream(data);
254 terrainModule.LoadFromStream(terrainPath, ms); 254 terrainModule.LoadFromStream(terrainPath, ms);
255 ms.Close(); 255 ms.Close();
256 256
257 m_log.DebugFormat("[ARCHIVER]: Restored terrain {0}", terrainPath); 257 m_log.DebugFormat("[ARCHIVER]: Restored terrain {0}", terrainPath);
258 258
259 return true; 259 return true;
260 } 260 }
261 } 261 }