diff options
author | Jeff Ames | 2008-08-18 00:39:10 +0000 |
---|---|---|
committer | Jeff Ames | 2008-08-18 00:39:10 +0000 |
commit | 6ef9d4da901a346c232458317cca6268da888e2e (patch) | |
tree | dd1d935b10f34f261839da9f9879c02322e8ede7 /OpenSim/Region/Environment/Modules/World/Archiver | |
parent | Update svn properties, minor formatting cleanup. (diff) | |
download | opensim-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')
9 files changed, 158 insertions, 158 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs index a5688ef..a76ff0d 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs | |||
@@ -39,33 +39,33 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
39 | /// The location of the archive control file | 39 | /// The location of the archive control file |
40 | /// </summary> | 40 | /// </summary> |
41 | public static readonly string CONTROL_FILE_PATH = "archive.xml"; | 41 | public static readonly string CONTROL_FILE_PATH = "archive.xml"; |
42 | 42 | ||
43 | /// <summary> | 43 | /// <summary> |
44 | /// Path for the assets held in an archive | 44 | /// Path for the assets held in an archive |
45 | /// </summary> | 45 | /// </summary> |
46 | public static readonly string ASSETS_PATH = "assets/"; | 46 | public static readonly string ASSETS_PATH = "assets/"; |
47 | 47 | ||
48 | /// <summary> | 48 | /// <summary> |
49 | /// Path for the assets metadata file | 49 | /// Path for the assets metadata file |
50 | /// </summary> | 50 | /// </summary> |
51 | //public static readonly string ASSETS_METADATA_PATH = "assets.xml"; | 51 | //public static readonly string ASSETS_METADATA_PATH = "assets.xml"; |
52 | 52 | ||
53 | /// <summary> | 53 | /// <summary> |
54 | /// Path for the prims file | 54 | /// Path for the prims file |
55 | /// </summary> | 55 | /// </summary> |
56 | public static readonly string OBJECTS_PATH = "objects/"; | 56 | public static readonly string OBJECTS_PATH = "objects/"; |
57 | 57 | ||
58 | /// <summary> | 58 | /// <summary> |
59 | /// Path for terrains. Technically these may be assets, but I think it's quite nice to split them out. | 59 | /// Path for terrains. Technically these may be assets, but I think it's quite nice to split them out. |
60 | /// </summary> | 60 | /// </summary> |
61 | public static readonly string TERRAINS_PATH = "terrains/"; | 61 | public static readonly string TERRAINS_PATH = "terrains/"; |
62 | 62 | ||
63 | /// <summary> | 63 | /// <summary> |
64 | /// Extensions used for asset types in the archive | 64 | /// Extensions used for asset types in the archive |
65 | /// </summary> | 65 | /// </summary> |
66 | public static readonly IDictionary<sbyte, string> ASSET_TYPE_TO_EXTENSION = new Dictionary<sbyte, string>(); | 66 | public static readonly IDictionary<sbyte, string> ASSET_TYPE_TO_EXTENSION = new Dictionary<sbyte, string>(); |
67 | public static readonly IDictionary<string, sbyte> EXTENSION_TO_ASSET_TYPE = new Dictionary<string, sbyte>(); | 67 | public static readonly IDictionary<string, sbyte> EXTENSION_TO_ASSET_TYPE = new Dictionary<string, sbyte>(); |
68 | 68 | ||
69 | static ArchiveConstants() | 69 | static ArchiveConstants() |
70 | { | 70 | { |
71 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Animation] = "_animation.bvh"; | 71 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Animation] = "_animation.bvh"; |
@@ -79,11 +79,11 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
79 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.LostAndFoundFolder] = "_lostandfoundfolder.txt"; // Not sure if we'll ever see this | 79 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.LostAndFoundFolder] = "_lostandfoundfolder.txt"; // Not sure if we'll ever see this |
80 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.LSLBytecode] = "_bytecode.lso"; | 80 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.LSLBytecode] = "_bytecode.lso"; |
81 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.LSLText] = "_script.lsl"; | 81 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.LSLText] = "_script.lsl"; |
82 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Notecard] = "_notecard.txt"; | 82 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Notecard] = "_notecard.txt"; |
83 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Object] = "_object.xml"; | 83 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Object] = "_object.xml"; |
84 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.RootFolder] = "_rootfolder.txt"; // Not sure if we'll ever see this | 84 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.RootFolder] = "_rootfolder.txt"; // Not sure if we'll ever see this |
85 | // disable warning: we know Script is obsolete, but need to support it | 85 | // disable warning: we know Script is obsolete, but need to support it |
86 | // anyhow | 86 | // anyhow |
87 | #pragma warning disable 0612 | 87 | #pragma warning disable 0612 |
88 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Script] = "_script.txt"; // Not sure if we'll ever see this | 88 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Script] = "_script.txt"; // Not sure if we'll ever see this |
89 | #pragma warning restore 0612 | 89 | #pragma warning restore 0612 |
@@ -93,8 +93,8 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
93 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SoundWAV] = "_sound.wav"; | 93 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SoundWAV] = "_sound.wav"; |
94 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Texture] = "_texture.jp2"; | 94 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Texture] = "_texture.jp2"; |
95 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TextureTGA] = "_texture.tga"; | 95 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TextureTGA] = "_texture.tga"; |
96 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TrashFolder] = "_trashfolder.txt"; // Not sure if we'll ever see this | 96 | ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TrashFolder] = "_trashfolder.txt"; // Not sure if we'll ever see this |
97 | 97 | ||
98 | EXTENSION_TO_ASSET_TYPE["_animation.bvh"] = (sbyte)AssetType.Animation; | 98 | EXTENSION_TO_ASSET_TYPE["_animation.bvh"] = (sbyte)AssetType.Animation; |
99 | EXTENSION_TO_ASSET_TYPE["_bodypart.txt"] = (sbyte)AssetType.Bodypart; | 99 | EXTENSION_TO_ASSET_TYPE["_bodypart.txt"] = (sbyte)AssetType.Bodypart; |
100 | EXTENSION_TO_ASSET_TYPE["_callingcard.txt"] = (sbyte)AssetType.CallingCard; | 100 | EXTENSION_TO_ASSET_TYPE["_callingcard.txt"] = (sbyte)AssetType.CallingCard; |
@@ -110,7 +110,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
110 | EXTENSION_TO_ASSET_TYPE["_object.xml"] = (sbyte)AssetType.Object; | 110 | EXTENSION_TO_ASSET_TYPE["_object.xml"] = (sbyte)AssetType.Object; |
111 | EXTENSION_TO_ASSET_TYPE["_rootfolder.txt"] = (sbyte)AssetType.RootFolder; | 111 | EXTENSION_TO_ASSET_TYPE["_rootfolder.txt"] = (sbyte)AssetType.RootFolder; |
112 | // disable warning: we know Script is obsolete, but need to support it | 112 | // disable warning: we know Script is obsolete, but need to support it |
113 | // anyhow | 113 | // anyhow |
114 | #pragma warning disable 0612 | 114 | #pragma warning disable 0612 |
115 | EXTENSION_TO_ASSET_TYPE["_script.txt"] = (sbyte)AssetType.Script; | 115 | EXTENSION_TO_ASSET_TYPE["_script.txt"] = (sbyte)AssetType.Script; |
116 | #pragma warning restore 0612 | 116 | #pragma warning restore 0612 |
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 | } |
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs index 0341a70..26d4797 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs | |||
@@ -61,8 +61,8 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
61 | 61 | ||
62 | public ArchiveWriteRequestExecution( | 62 | public ArchiveWriteRequestExecution( |
63 | List<SceneObjectGroup> sceneObjects, | 63 | List<SceneObjectGroup> sceneObjects, |
64 | ITerrainModule terrainModule, | 64 | ITerrainModule terrainModule, |
65 | IRegionSerialiser serialiser, | 65 | IRegionSerialiser serialiser, |
66 | string sceneName, | 66 | string sceneName, |
67 | string savePath) | 67 | string savePath) |
68 | { | 68 | { |
@@ -79,37 +79,37 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
79 | { | 79 | { |
80 | m_log.DebugFormat("[ARCHIVER]: Could not find asset {0}", uuid); | 80 | m_log.DebugFormat("[ARCHIVER]: Could not find asset {0}", uuid); |
81 | } | 81 | } |
82 | 82 | ||
83 | m_log.InfoFormat( | 83 | m_log.InfoFormat( |
84 | "[ARCHIVER]: Received {0} of {1} assets requested", assetsFound.Count, assetsFound.Count + assetsNotFoundUuids.Count); | 84 | "[ARCHIVER]: Received {0} of {1} assets requested", assetsFound.Count, assetsFound.Count + assetsNotFoundUuids.Count); |
85 | 85 | ||
86 | TarArchiveWriter archive = new TarArchiveWriter(); | 86 | TarArchiveWriter archive = new TarArchiveWriter(); |
87 | 87 | ||
88 | // Write out control file | 88 | // Write out control file |
89 | archive.AddFile(ArchiveConstants.CONTROL_FILE_PATH, CreateControlFile()); | 89 | archive.AddFile(ArchiveConstants.CONTROL_FILE_PATH, CreateControlFile()); |
90 | 90 | ||
91 | // Write out terrain | 91 | // Write out terrain |
92 | string terrainPath = String.Format("{0}{1}.r32", ArchiveConstants.TERRAINS_PATH, m_sceneName); | 92 | string terrainPath = String.Format("{0}{1}.r32", ArchiveConstants.TERRAINS_PATH, m_sceneName); |
93 | MemoryStream ms = new MemoryStream(); | 93 | MemoryStream ms = new MemoryStream(); |
94 | m_terrainModule.SaveToStream(terrainPath, ms); | 94 | m_terrainModule.SaveToStream(terrainPath, ms); |
95 | archive.AddFile(terrainPath, ms.ToArray()); | 95 | archive.AddFile(terrainPath, ms.ToArray()); |
96 | ms.Close(); | 96 | ms.Close(); |
97 | 97 | ||
98 | // Write out scene object metadata | 98 | // Write out scene object metadata |
99 | foreach (SceneObjectGroup sceneObject in m_sceneObjects) | 99 | foreach (SceneObjectGroup sceneObject in m_sceneObjects) |
100 | { | 100 | { |
101 | //m_log.DebugFormat("[ARCHIVER]: Saving {0} {1}, {2}", entity.Name, entity.UUID, entity.GetType()); | 101 | //m_log.DebugFormat("[ARCHIVER]: Saving {0} {1}, {2}", entity.Name, entity.UUID, entity.GetType()); |
102 | 102 | ||
103 | LLVector3 position = sceneObject.AbsolutePosition; | 103 | LLVector3 position = sceneObject.AbsolutePosition; |
104 | 104 | ||
105 | string serializedObject = m_serialiser.SaveGroupToXml2(sceneObject); | 105 | string serializedObject = m_serialiser.SaveGroupToXml2(sceneObject); |
106 | string filename | 106 | string filename |
107 | = string.Format( | 107 | = string.Format( |
108 | "{0}{1}_{2:000}-{3:000}-{4:000}__{5}.xml", | 108 | "{0}{1}_{2:000}-{3:000}-{4:000}__{5}.xml", |
109 | ArchiveConstants.OBJECTS_PATH, sceneObject.Name, | 109 | ArchiveConstants.OBJECTS_PATH, sceneObject.Name, |
110 | Math.Round(position.X), Math.Round(position.Y), Math.Round(position.Z), | 110 | Math.Round(position.X), Math.Round(position.Y), Math.Round(position.Z), |
111 | sceneObject.UUID); | 111 | sceneObject.UUID); |
112 | 112 | ||
113 | archive.AddFile(filename, serializedObject); | 113 | archive.AddFile(filename, serializedObject); |
114 | } | 114 | } |
115 | 115 | ||
@@ -120,8 +120,8 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
120 | archive.WriteTar(new GZipStream(new FileStream(m_savePath, FileMode.Create), CompressionMode.Compress)); | 120 | archive.WriteTar(new GZipStream(new FileStream(m_savePath, FileMode.Create), CompressionMode.Compress)); |
121 | 121 | ||
122 | m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive {0}", m_savePath); | 122 | m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive {0}", m_savePath); |
123 | } | 123 | } |
124 | 124 | ||
125 | /// <summary> | 125 | /// <summary> |
126 | /// Create the control file for this archive | 126 | /// Create the control file for this archive |
127 | /// </summary> | 127 | /// </summary> |
@@ -136,13 +136,13 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
136 | xtw.WriteAttributeString("major_version", "0"); | 136 | xtw.WriteAttributeString("major_version", "0"); |
137 | xtw.WriteAttributeString("minor_version", "1"); | 137 | xtw.WriteAttributeString("minor_version", "1"); |
138 | xtw.WriteEndElement(); | 138 | xtw.WriteEndElement(); |
139 | 139 | ||
140 | xtw.Flush(); | 140 | xtw.Flush(); |
141 | xtw.Close(); | 141 | xtw.Close(); |
142 | 142 | ||
143 | String s = sw.ToString(); | 143 | String s = sw.ToString(); |
144 | sw.Close(); | 144 | sw.Close(); |
145 | 145 | ||
146 | return s; | 146 | return s; |
147 | } | 147 | } |
148 | } | 148 | } |
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs index 327808a..20e15ab 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestPreparation.cs | |||
@@ -52,14 +52,14 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
52 | 52 | ||
53 | protected Scene m_scene; | 53 | protected Scene m_scene; |
54 | protected string m_savePath; | 54 | protected string m_savePath; |
55 | 55 | ||
56 | /// <summary> | 56 | /// <summary> |
57 | /// Used for identifying uuids embedded in scripts | 57 | /// Used for identifying uuids embedded in scripts |
58 | /// </summary> | 58 | /// </summary> |
59 | protected static readonly Regex m_uuidRegex | 59 | protected static readonly Regex m_uuidRegex |
60 | = new Regex( | 60 | = new Regex( |
61 | "[0-9a-eA-E]{8}-[0-9a-eA-E]{4}-[0-9a-eA-E]{4}-[0-9a-eA-E]{4}-[0-9a-eA-E]{12}", | 61 | "[0-9a-eA-E]{8}-[0-9a-eA-E]{4}-[0-9a-eA-E]{4}-[0-9a-eA-E]{4}-[0-9a-eA-E]{12}", |
62 | RegexOptions.Compiled); | 62 | RegexOptions.Compiled); |
63 | 63 | ||
64 | /// <summary> | 64 | /// <summary> |
65 | /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate | 65 | /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate |
@@ -93,9 +93,9 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
93 | Monitor.Pulse(this); | 93 | Monitor.Pulse(this); |
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
97 | /// <summary> | 97 | /// <summary> |
98 | /// Get an asset synchronously, potentially using an asynchronous callback. If the | 98 | /// Get an asset synchronously, potentially using an asynchronous callback. If the |
99 | /// asynchronous callback is used, we will wait for it to complete. | 99 | /// asynchronous callback is used, we will wait for it to complete. |
100 | /// </summary> | 100 | /// </summary> |
101 | /// <param name="uuid"></param> | 101 | /// <param name="uuid"></param> |
@@ -118,11 +118,11 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
118 | Monitor.Wait(this); | 118 | Monitor.Wait(this); |
119 | m_waitingForObjectAsset = false; | 119 | m_waitingForObjectAsset = false; |
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | return m_requestedObjectAsset; | 123 | return m_requestedObjectAsset; |
124 | } | 124 | } |
125 | 125 | ||
126 | /// <summary> | 126 | /// <summary> |
127 | /// Record the asset uuids embedded within the given script. | 127 | /// Record the asset uuids embedded within the given script. |
128 | /// </summary> | 128 | /// </summary> |
@@ -138,16 +138,16 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
138 | //m_log.DebugFormat("[ARCHIVER]: Script {0}", script); | 138 | //m_log.DebugFormat("[ARCHIVER]: Script {0}", script); |
139 | MatchCollection uuidMatches = m_uuidRegex.Matches(script); | 139 | MatchCollection uuidMatches = m_uuidRegex.Matches(script); |
140 | //m_log.DebugFormat("[ARCHIVER]: Found {0} matches in script", uuidMatches.Count); | 140 | //m_log.DebugFormat("[ARCHIVER]: Found {0} matches in script", uuidMatches.Count); |
141 | 141 | ||
142 | foreach (Match uuidMatch in uuidMatches) | 142 | foreach (Match uuidMatch in uuidMatches) |
143 | { | 143 | { |
144 | LLUUID uuid = new LLUUID(uuidMatch.Value); | 144 | LLUUID uuid = new LLUUID(uuidMatch.Value); |
145 | //m_log.DebugFormat("[ARCHIVER]: Recording {0} in script", uuid); | 145 | //m_log.DebugFormat("[ARCHIVER]: Recording {0} in script", uuid); |
146 | assetUuids[uuid] = 1; | 146 | assetUuids[uuid] = 1; |
147 | } | 147 | } |
148 | } | 148 | } |
149 | } | 149 | } |
150 | 150 | ||
151 | /// <summary> | 151 | /// <summary> |
152 | /// Record the uuids referenced by the given wearable asset | 152 | /// Record the uuids referenced by the given wearable asset |
153 | /// </summary> | 153 | /// </summary> |
@@ -159,25 +159,25 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
159 | //m_log.Debug(new System.Text.ASCIIEncoding().GetString(bodypartAsset.Data)); | 159 | //m_log.Debug(new System.Text.ASCIIEncoding().GetString(bodypartAsset.Data)); |
160 | AssetWearable wearableAsset = new AssetBodypart(assetBase.Data); | 160 | AssetWearable wearableAsset = new AssetBodypart(assetBase.Data); |
161 | wearableAsset.Decode(); | 161 | wearableAsset.Decode(); |
162 | 162 | ||
163 | //m_log.DebugFormat( | 163 | //m_log.DebugFormat( |
164 | // "[ARCHIVER]: Wearable asset {0} references {1} assets", wearableAssetUuid, wearableAsset.Textures.Count); | 164 | // "[ARCHIVER]: Wearable asset {0} references {1} assets", wearableAssetUuid, wearableAsset.Textures.Count); |
165 | 165 | ||
166 | foreach (LLUUID uuid in wearableAsset.Textures.Values) | 166 | foreach (LLUUID uuid in wearableAsset.Textures.Values) |
167 | { | 167 | { |
168 | //m_log.DebugFormat("[ARCHIVER]: Got bodypart uuid {0}", uuid); | 168 | //m_log.DebugFormat("[ARCHIVER]: Got bodypart uuid {0}", uuid); |
169 | assetUuids[uuid] = 1; | 169 | assetUuids[uuid] = 1; |
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
173 | /// <summary> | 173 | /// <summary> |
174 | /// Get all the asset uuids associated with a given object. This includes both those directly associated with | 174 | /// Get all the asset uuids associated with a given object. This includes both those directly associated with |
175 | /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained | 175 | /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained |
176 | /// within this object). | 176 | /// within this object). |
177 | /// </summary> | 177 | /// </summary> |
178 | /// <param name="sceneObject"></param> | 178 | /// <param name="sceneObject"></param> |
179 | /// <param name="assetUuids"></param> | 179 | /// <param name="assetUuids"></param> |
180 | protected void GetSceneObjectAssetUuids(LLUUID sceneObjectUuid, IDictionary<LLUUID, int> assetUuids) | 180 | protected void GetSceneObjectAssetUuids(LLUUID sceneObjectUuid, IDictionary<LLUUID, int> assetUuids) |
181 | { | 181 | { |
182 | AssetBase objectAsset = GetAsset(sceneObjectUuid); | 182 | AssetBase objectAsset = GetAsset(sceneObjectUuid); |
183 | 183 | ||
@@ -186,7 +186,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
186 | string xml = Helpers.FieldToUTF8String(objectAsset.Data); | 186 | string xml = Helpers.FieldToUTF8String(objectAsset.Data); |
187 | SceneObjectGroup sog = new SceneObjectGroup(m_scene, m_scene.RegionInfo.RegionHandle, xml); | 187 | SceneObjectGroup sog = new SceneObjectGroup(m_scene, m_scene.RegionInfo.RegionHandle, xml); |
188 | GetSceneObjectAssetUuids(sog, assetUuids); | 188 | GetSceneObjectAssetUuids(sog, assetUuids); |
189 | } | 189 | } |
190 | } | 190 | } |
191 | 191 | ||
192 | /// <summary> | 192 | /// <summary> |
@@ -209,10 +209,10 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
209 | try | 209 | try |
210 | { | 210 | { |
211 | LLObject.TextureEntry textureEntry = part.Shape.Textures; | 211 | LLObject.TextureEntry textureEntry = part.Shape.Textures; |
212 | 212 | ||
213 | // Get the prim's default texture. This will be used for faces which don't have their own texture | 213 | // Get the prim's default texture. This will be used for faces which don't have their own texture |
214 | assetUuids[textureEntry.DefaultTexture.TextureID] = 1; | 214 | assetUuids[textureEntry.DefaultTexture.TextureID] = 1; |
215 | 215 | ||
216 | // XXX: Not a great way to iterate through face textures, but there's no | 216 | // XXX: Not a great way to iterate through face textures, but there's no |
217 | // other method available to tell how many faces there actually are | 217 | // other method available to tell how many faces there actually are |
218 | //int i = 0; | 218 | //int i = 0; |
@@ -224,15 +224,15 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
224 | assetUuids[texture.TextureID] = 1; | 224 | assetUuids[texture.TextureID] = 1; |
225 | } | 225 | } |
226 | } | 226 | } |
227 | 227 | ||
228 | foreach (TaskInventoryItem tii in part.TaskInventory.Values) | 228 | foreach (TaskInventoryItem tii in part.TaskInventory.Values) |
229 | { | 229 | { |
230 | //m_log.DebugFormat("[ARCHIVER]: Analysing item asset type {0}", tii.Type); | 230 | //m_log.DebugFormat("[ARCHIVER]: Analysing item asset type {0}", tii.Type); |
231 | 231 | ||
232 | if (!assetUuids.ContainsKey(tii.AssetID)) | 232 | if (!assetUuids.ContainsKey(tii.AssetID)) |
233 | { | 233 | { |
234 | assetUuids[tii.AssetID] = 1; | 234 | assetUuids[tii.AssetID] = 1; |
235 | 235 | ||
236 | if ((int)AssetType.Bodypart == tii.Type || ((int)AssetType.Clothing == tii.Type)) | 236 | if ((int)AssetType.Bodypart == tii.Type || ((int)AssetType.Clothing == tii.Type)) |
237 | { | 237 | { |
238 | GetWearableAssetUuids(tii.AssetID, assetUuids); | 238 | GetWearableAssetUuids(tii.AssetID, assetUuids); |
@@ -275,20 +275,20 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
275 | if (entity is SceneObjectGroup) | 275 | if (entity is SceneObjectGroup) |
276 | sceneObjects.Add((SceneObjectGroup)entity); | 276 | sceneObjects.Add((SceneObjectGroup)entity); |
277 | } | 277 | } |
278 | 278 | ||
279 | foreach (SceneObjectGroup sceneObject in sceneObjects) | 279 | foreach (SceneObjectGroup sceneObject in sceneObjects) |
280 | { | 280 | { |
281 | GetSceneObjectAssetUuids(sceneObject, assetUuids); | 281 | GetSceneObjectAssetUuids(sceneObject, assetUuids); |
282 | } | 282 | } |
283 | 283 | ||
284 | m_log.DebugFormat( | 284 | m_log.DebugFormat( |
285 | "[ARCHIVER]: {0} scene objects to serialize requiring save of {1} assets", | 285 | "[ARCHIVER]: {0} scene objects to serialize requiring save of {1} assets", |
286 | sceneObjects.Count, assetUuids.Count); | 286 | sceneObjects.Count, assetUuids.Count); |
287 | 287 | ||
288 | // Asynchronously request all the assets required to perform this archive operation | 288 | // Asynchronously request all the assets required to perform this archive operation |
289 | ArchiveWriteRequestExecution awre | 289 | ArchiveWriteRequestExecution awre |
290 | = new ArchiveWriteRequestExecution( | 290 | = new ArchiveWriteRequestExecution( |
291 | sceneObjects, | 291 | sceneObjects, |
292 | m_scene.RequestModuleInterface<ITerrainModule>(), | 292 | m_scene.RequestModuleInterface<ITerrainModule>(), |
293 | m_scene.RequestModuleInterface<IRegionSerialiser>(), | 293 | m_scene.RequestModuleInterface<IRegionSerialiser>(), |
294 | m_scene.RegionInfo.RegionName, | 294 | m_scene.RegionInfo.RegionName, |
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs index 2704224..708bed3 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsArchiver.cs | |||
@@ -41,17 +41,17 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
41 | public class AssetsArchiver | 41 | public class AssetsArchiver |
42 | { | 42 | { |
43 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 43 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
44 | 44 | ||
45 | /// <summary> | 45 | /// <summary> |
46 | /// Archive assets | 46 | /// Archive assets |
47 | /// </summary> | 47 | /// </summary> |
48 | protected IDictionary<LLUUID, AssetBase> m_assets; | 48 | protected IDictionary<LLUUID, AssetBase> m_assets; |
49 | 49 | ||
50 | public AssetsArchiver(IDictionary<LLUUID, AssetBase> assets) | 50 | public AssetsArchiver(IDictionary<LLUUID, AssetBase> assets) |
51 | { | 51 | { |
52 | m_assets = assets; | 52 | m_assets = assets; |
53 | } | 53 | } |
54 | 54 | ||
55 | /// <summary> | 55 | /// <summary> |
56 | /// Archive the assets given to this archiver to the given archive. | 56 | /// Archive the assets given to this archiver to the given archive. |
57 | /// </summary> | 57 | /// </summary> |
@@ -70,44 +70,44 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
70 | { | 70 | { |
71 | StringWriter sw = new StringWriter(); | 71 | StringWriter sw = new StringWriter(); |
72 | XmlTextWriter xtw = new XmlTextWriter(sw); | 72 | XmlTextWriter xtw = new XmlTextWriter(sw); |
73 | 73 | ||
74 | xtw.Formatting = Formatting.Indented; | 74 | xtw.Formatting = Formatting.Indented; |
75 | xtw.WriteStartDocument(); | 75 | xtw.WriteStartDocument(); |
76 | 76 | ||
77 | xtw.WriteStartElement("assets"); | 77 | xtw.WriteStartElement("assets"); |
78 | 78 | ||
79 | foreach (LLUUID uuid in m_assets.Keys) | 79 | foreach (LLUUID uuid in m_assets.Keys) |
80 | { | 80 | { |
81 | AssetBase asset = m_assets[uuid]; | 81 | AssetBase asset = m_assets[uuid]; |
82 | 82 | ||
83 | if (asset != null) | 83 | if (asset != null) |
84 | { | 84 | { |
85 | xtw.WriteStartElement("asset"); | 85 | xtw.WriteStartElement("asset"); |
86 | 86 | ||
87 | string extension = string.Empty; | 87 | string extension = string.Empty; |
88 | 88 | ||
89 | if (ArchiveConstants.ASSET_TYPE_TO_EXTENSION.ContainsKey(asset.Type)) | 89 | if (ArchiveConstants.ASSET_TYPE_TO_EXTENSION.ContainsKey(asset.Type)) |
90 | { | 90 | { |
91 | extension = ArchiveConstants.ASSET_TYPE_TO_EXTENSION[asset.Type]; | 91 | extension = ArchiveConstants.ASSET_TYPE_TO_EXTENSION[asset.Type]; |
92 | } | 92 | } |
93 | 93 | ||
94 | xtw.WriteElementString("filename", uuid.ToString() + extension); | 94 | xtw.WriteElementString("filename", uuid.ToString() + extension); |
95 | 95 | ||
96 | xtw.WriteElementString("name", asset.Name); | 96 | xtw.WriteElementString("name", asset.Name); |
97 | xtw.WriteElementString("description", asset.Description); | 97 | xtw.WriteElementString("description", asset.Description); |
98 | xtw.WriteElementString("asset-type", asset.Type.ToString()); | 98 | xtw.WriteElementString("asset-type", asset.Type.ToString()); |
99 | 99 | ||
100 | xtw.WriteEndElement(); | 100 | xtw.WriteEndElement(); |
101 | } | 101 | } |
102 | } | 102 | } |
103 | 103 | ||
104 | xtw.WriteEndElement(); | 104 | xtw.WriteEndElement(); |
105 | 105 | ||
106 | xtw.WriteEndDocument(); | 106 | xtw.WriteEndDocument(); |
107 | 107 | ||
108 | archive.AddFile("assets.xml", sw.ToString()); | 108 | archive.AddFile("assets.xml", sw.ToString()); |
109 | } | 109 | } |
110 | 110 | ||
111 | /// <summary> | 111 | /// <summary> |
112 | /// Write asset data files to the given archive | 112 | /// Write asset data files to the given archive |
113 | /// </summary> | 113 | /// </summary> |
@@ -116,18 +116,18 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
116 | { | 116 | { |
117 | // It appears that gtar, at least, doesn't need the intermediate directory entries in the tar | 117 | // It appears that gtar, at least, doesn't need the intermediate directory entries in the tar |
118 | //archive.AddDir("assets"); | 118 | //archive.AddDir("assets"); |
119 | 119 | ||
120 | foreach (LLUUID uuid in m_assets.Keys) | 120 | foreach (LLUUID uuid in m_assets.Keys) |
121 | { | 121 | { |
122 | AssetBase asset = m_assets[uuid]; | 122 | AssetBase asset = m_assets[uuid]; |
123 | 123 | ||
124 | string extension = string.Empty; | 124 | string extension = string.Empty; |
125 | 125 | ||
126 | if (ArchiveConstants.ASSET_TYPE_TO_EXTENSION.ContainsKey(asset.Type)) | 126 | if (ArchiveConstants.ASSET_TYPE_TO_EXTENSION.ContainsKey(asset.Type)) |
127 | { | 127 | { |
128 | extension = ArchiveConstants.ASSET_TYPE_TO_EXTENSION[asset.Type]; | 128 | extension = ArchiveConstants.ASSET_TYPE_TO_EXTENSION[asset.Type]; |
129 | } | 129 | } |
130 | 130 | ||
131 | archive.AddFile( | 131 | archive.AddFile( |
132 | ArchiveConstants.ASSETS_PATH + uuid.ToString() + extension, | 132 | ArchiveConstants.ASSETS_PATH + uuid.ToString() + extension, |
133 | asset.Data); | 133 | asset.Data); |
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsDearchiver.cs b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsDearchiver.cs index 284a39e..17abb24 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsDearchiver.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsDearchiver.cs | |||
@@ -43,9 +43,9 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
43 | public class AssetsDearchiver | 43 | public class AssetsDearchiver |
44 | { | 44 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | protected static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding(); | 47 | protected static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding(); |
48 | 48 | ||
49 | /// <summary> | 49 | /// <summary> |
50 | /// Store for asset data we received before we get the metadata | 50 | /// Store for asset data we received before we get the metadata |
51 | /// </summary> | 51 | /// </summary> |
@@ -55,17 +55,17 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
55 | /// Asset metadata. Is null if asset metadata isn't yet available. | 55 | /// Asset metadata. Is null if asset metadata isn't yet available. |
56 | /// </summary> | 56 | /// </summary> |
57 | protected Dictionary<string, AssetMetadata> m_metadata; | 57 | protected Dictionary<string, AssetMetadata> m_metadata; |
58 | 58 | ||
59 | /// <summary> | 59 | /// <summary> |
60 | /// Cache to which dearchived assets will be added | 60 | /// Cache to which dearchived assets will be added |
61 | /// </summary> | 61 | /// </summary> |
62 | protected AssetCache m_cache; | 62 | protected AssetCache m_cache; |
63 | 63 | ||
64 | public AssetsDearchiver(AssetCache cache) | 64 | public AssetsDearchiver(AssetCache cache) |
65 | { | 65 | { |
66 | m_cache = cache; | 66 | m_cache = cache; |
67 | } | 67 | } |
68 | 68 | ||
69 | /// <summary> | 69 | /// <summary> |
70 | /// Add asset data to the dearchiver | 70 | /// Add asset data to the dearchiver |
71 | /// </summary> | 71 | /// </summary> |
@@ -82,7 +82,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
82 | ResolveAssetData(assetFilename, data); | 82 | ResolveAssetData(assetFilename, data); |
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | /// <summary> | 86 | /// <summary> |
87 | /// Add asset metadata xml | 87 | /// Add asset metadata xml |
88 | /// </summary> | 88 | /// </summary> |
@@ -90,39 +90,39 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
90 | public void AddAssetMetadata(string xml) | 90 | public void AddAssetMetadata(string xml) |
91 | { | 91 | { |
92 | m_metadata = new Dictionary<string, AssetMetadata>(); | 92 | m_metadata = new Dictionary<string, AssetMetadata>(); |
93 | 93 | ||
94 | StringReader sr = new StringReader(xml); | 94 | StringReader sr = new StringReader(xml); |
95 | XmlTextReader reader = new XmlTextReader(sr); | 95 | XmlTextReader reader = new XmlTextReader(sr); |
96 | 96 | ||
97 | reader.ReadStartElement("assets"); | 97 | reader.ReadStartElement("assets"); |
98 | reader.Read(); | 98 | reader.Read(); |
99 | 99 | ||
100 | while (reader.Name.Equals("asset")) | 100 | while (reader.Name.Equals("asset")) |
101 | { | 101 | { |
102 | reader.Read(); | 102 | reader.Read(); |
103 | 103 | ||
104 | AssetMetadata metadata = new AssetMetadata(); | 104 | AssetMetadata metadata = new AssetMetadata(); |
105 | 105 | ||
106 | string filename = reader.ReadElementString("filename"); | 106 | string filename = reader.ReadElementString("filename"); |
107 | m_log.DebugFormat("[DEARCHIVER]: Reading node {0}", filename); | 107 | m_log.DebugFormat("[DEARCHIVER]: Reading node {0}", filename); |
108 | 108 | ||
109 | metadata.Name = reader.ReadElementString("name"); | 109 | metadata.Name = reader.ReadElementString("name"); |
110 | metadata.Description = reader.ReadElementString("description"); | 110 | metadata.Description = reader.ReadElementString("description"); |
111 | metadata.AssetType = Convert.ToSByte(reader.ReadElementString("asset-type")); | 111 | metadata.AssetType = Convert.ToSByte(reader.ReadElementString("asset-type")); |
112 | 112 | ||
113 | m_metadata[filename] = metadata; | 113 | m_metadata[filename] = metadata; |
114 | 114 | ||
115 | // Read asset end tag | 115 | // Read asset end tag |
116 | reader.ReadEndElement(); | 116 | reader.ReadEndElement(); |
117 | 117 | ||
118 | reader.Read(); | 118 | reader.Read(); |
119 | } | 119 | } |
120 | 120 | ||
121 | m_log.DebugFormat("[DEARCHIVER]: Resolved {0} items of asset metadata", m_metadata.Count); | 121 | m_log.DebugFormat("[DEARCHIVER]: Resolved {0} items of asset metadata", m_metadata.Count); |
122 | 122 | ||
123 | ResolvePendingAssetData(); | 123 | ResolvePendingAssetData(); |
124 | } | 124 | } |
125 | 125 | ||
126 | /// <summary> | 126 | /// <summary> |
127 | /// Resolve asset data that we collected before receiving the metadata | 127 | /// Resolve asset data that we collected before receiving the metadata |
128 | /// </summary> | 128 | /// </summary> |
@@ -133,7 +133,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
133 | ResolveAssetData(filename, m_assetDataAwaitingMetadata[filename]); | 133 | ResolveAssetData(filename, m_assetDataAwaitingMetadata[filename]); |
134 | } | 134 | } |
135 | } | 135 | } |
136 | 136 | ||
137 | /// <summary> | 137 | /// <summary> |
138 | /// Resolve a new piece of asset data against stored metadata | 138 | /// Resolve a new piece of asset data against stored metadata |
139 | /// </summary> | 139 | /// </summary> |
@@ -143,11 +143,11 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
143 | { | 143 | { |
144 | // Right now we're nastily obtaining the lluuid from the filename | 144 | // Right now we're nastily obtaining the lluuid from the filename |
145 | string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length); | 145 | string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length); |
146 | 146 | ||
147 | if (m_metadata.ContainsKey(filename)) | 147 | if (m_metadata.ContainsKey(filename)) |
148 | { | 148 | { |
149 | AssetMetadata metadata = m_metadata[filename]; | 149 | AssetMetadata metadata = m_metadata[filename]; |
150 | 150 | ||
151 | if (ArchiveConstants.ASSET_TYPE_TO_EXTENSION.ContainsKey(metadata.AssetType)) | 151 | if (ArchiveConstants.ASSET_TYPE_TO_EXTENSION.ContainsKey(metadata.AssetType)) |
152 | { | 152 | { |
153 | string extension = ArchiveConstants.ASSET_TYPE_TO_EXTENSION[metadata.AssetType]; | 153 | string extension = ArchiveConstants.ASSET_TYPE_TO_EXTENSION[metadata.AssetType]; |
@@ -166,11 +166,11 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
166 | else | 166 | else |
167 | { | 167 | { |
168 | m_log.ErrorFormat( | 168 | m_log.ErrorFormat( |
169 | "[DEARCHIVER]: Tried to dearchive data with filename {0} without any corresponding metadata", | 169 | "[DEARCHIVER]: Tried to dearchive data with filename {0} without any corresponding metadata", |
170 | assetPath); | 170 | assetPath); |
171 | } | 171 | } |
172 | } | 172 | } |
173 | 173 | ||
174 | /// <summary> | 174 | /// <summary> |
175 | /// Metadata for an asset | 175 | /// Metadata for an asset |
176 | /// </summary> | 176 | /// </summary> |
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsRequest.cs index 6ffbcbb..2164f7e 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/AssetsRequest.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/AssetsRequest.cs | |||
@@ -43,12 +43,12 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
43 | class AssetsRequest | 43 | class AssetsRequest |
44 | { | 44 | { |
45 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | /// <summary> | 47 | /// <summary> |
48 | /// uuids to request | 48 | /// uuids to request |
49 | /// </summary> | 49 | /// </summary> |
50 | protected ICollection<LLUUID> m_uuids; | 50 | protected ICollection<LLUUID> m_uuids; |
51 | 51 | ||
52 | /// <summary> | 52 | /// <summary> |
53 | /// Callback used when all the assets requested have been received. | 53 | /// Callback used when all the assets requested have been received. |
54 | /// </summary> | 54 | /// </summary> |
@@ -58,7 +58,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
58 | /// Assets retrieved in this request | 58 | /// Assets retrieved in this request |
59 | /// </summary> | 59 | /// </summary> |
60 | protected Dictionary<LLUUID, AssetBase> m_assets = new Dictionary<LLUUID, AssetBase>(); | 60 | protected Dictionary<LLUUID, AssetBase> m_assets = new Dictionary<LLUUID, AssetBase>(); |
61 | 61 | ||
62 | /// <summary> | 62 | /// <summary> |
63 | /// Maintain a list of assets that could not be found. This will be passed back to the requester. | 63 | /// Maintain a list of assets that could not be found. This will be passed back to the requester. |
64 | /// </summary> | 64 | /// </summary> |
@@ -81,7 +81,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
81 | m_assetCache = assetCache; | 81 | m_assetCache = assetCache; |
82 | m_repliesRequired = uuids.Count; | 82 | m_repliesRequired = uuids.Count; |
83 | } | 83 | } |
84 | 84 | ||
85 | protected internal void Execute() | 85 | protected internal void Execute() |
86 | { | 86 | { |
87 | // We can stop here if there are no assets to fetch | 87 | // We can stop here if there are no assets to fetch |
@@ -105,7 +105,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
105 | m_assets[assetID] = asset; | 105 | m_assets[assetID] = asset; |
106 | else | 106 | else |
107 | m_notFoundAssetUuids.Add(assetID); | 107 | m_notFoundAssetUuids.Add(assetID); |
108 | 108 | ||
109 | //m_log.DebugFormat( | 109 | //m_log.DebugFormat( |
110 | // "[ARCHIVER]: Received {0} assets and notification of {1} missing assets", m_assets.Count, m_notFoundAssetUuids.Count); | 110 | // "[ARCHIVER]: Received {0} assets and notification of {1} missing assets", m_assets.Count, m_notFoundAssetUuids.Count); |
111 | 111 | ||
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs index 585d1d4..4e000cc 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs | |||
@@ -69,9 +69,9 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
69 | public byte[] ReadEntry(out string filePath) | 69 | public byte[] ReadEntry(out string filePath) |
70 | { | 70 | { |
71 | filePath = String.Empty; | 71 | filePath = String.Empty; |
72 | 72 | ||
73 | TarHeader header = ReadHeader(); | 73 | TarHeader header = ReadHeader(); |
74 | 74 | ||
75 | if (null == header) | 75 | if (null == header) |
76 | return null; | 76 | return null; |
77 | 77 | ||
@@ -98,14 +98,14 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
98 | /// </summary> | 98 | /// </summary> |
99 | /// <returns>A tar header struct. null if we have reached the end of the archive.</returns> | 99 | /// <returns>A tar header struct. null if we have reached the end of the archive.</returns> |
100 | protected TarHeader ReadHeader() | 100 | protected TarHeader ReadHeader() |
101 | { | 101 | { |
102 | byte[] header = m_br.ReadBytes(512); | 102 | byte[] header = m_br.ReadBytes(512); |
103 | 103 | ||
104 | // If we've reached the end of the archive we'll be in null block territory, which means | 104 | // If we've reached the end of the archive we'll be in null block territory, which means |
105 | // the next byte will be 0 | 105 | // the next byte will be 0 |
106 | if (header[0] == 0) | 106 | if (header[0] == 0) |
107 | return null; | 107 | return null; |
108 | 108 | ||
109 | TarHeader tarHeader = new TarHeader(); | 109 | TarHeader tarHeader = new TarHeader(); |
110 | 110 | ||
111 | tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100); | 111 | tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100); |
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveWriter.cs b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveWriter.cs index f70a93d..83b9250 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveWriter.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveWriter.cs | |||
@@ -54,10 +54,10 @@ namespace OpenSim.Region.Environment | |||
54 | // Directories are signalled by a final / | 54 | // Directories are signalled by a final / |
55 | if (!dirName.EndsWith("/")) | 55 | if (!dirName.EndsWith("/")) |
56 | dirName += "/"; | 56 | dirName += "/"; |
57 | 57 | ||
58 | AddFile(dirName, new byte[0]); | 58 | AddFile(dirName, new byte[0]); |
59 | } | 59 | } |
60 | 60 | ||
61 | /// <summary> | 61 | /// <summary> |
62 | /// Add a file to the tar archive | 62 | /// Add a file to the tar archive |
63 | /// </summary> | 63 | /// </summary> |
@@ -161,7 +161,7 @@ namespace OpenSim.Region.Environment | |||
161 | if (data.Length % 512 != 0) | 161 | if (data.Length % 512 != 0) |
162 | { | 162 | { |
163 | int paddingRequired = 512 - (data.Length % 512); | 163 | int paddingRequired = 512 - (data.Length % 512); |
164 | 164 | ||
165 | //m_log.DebugFormat("[TAR ARCHIVE WRITER]: Padding data with {0} bytes", paddingRequired); | 165 | //m_log.DebugFormat("[TAR ARCHIVE WRITER]: Padding data with {0} bytes", paddingRequired); |
166 | 166 | ||
167 | byte[] padding = new byte[paddingRequired]; | 167 | byte[] padding = new byte[paddingRequired]; |