diff options
author | Justin Clarke Casey | 2009-02-10 18:43:36 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2009-02-10 18:43:36 +0000 |
commit | 25bc7a44cdb4809b184c81231d2d99ec3dcbaf72 (patch) | |
tree | 914cd06b9fe7a9d980ba60f961332d01c6c181eb /OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | |
parent | * extend load oar test to check that an object was actually loaded (diff) | |
download | opensim-SC_OLD-25bc7a44cdb4809b184c81231d2d99ec3dcbaf72.zip opensim-SC_OLD-25bc7a44cdb4809b184c81231d2d99ec3dcbaf72.tar.gz opensim-SC_OLD-25bc7a44cdb4809b184c81231d2d99ec3dcbaf72.tar.bz2 opensim-SC_OLD-25bc7a44cdb4809b184c81231d2d99ec3dcbaf72.tar.xz |
* Implement merging of oars in code
* Not fully tested yet and not yet available as an option from the user console
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 3218abc..0cc1f86 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | |||
@@ -51,26 +51,33 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
51 | 51 | ||
52 | private static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding(); | 52 | private static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding(); |
53 | 53 | ||
54 | private Scene m_scene; | 54 | private Scene m_scene; |
55 | private Stream m_loadStream; | 55 | private Stream m_loadStream; |
56 | private string m_errorMessage; | 56 | private string m_errorMessage; |
57 | |||
58 | /// <value> | ||
59 | /// Should the archive being loaded be merged with what is already on the region? | ||
60 | /// </value> | ||
61 | private bool m_merge; | ||
57 | 62 | ||
58 | /// <summary> | 63 | /// <summary> |
59 | /// Used to cache lookups for valid uuids. | 64 | /// Used to cache lookups for valid uuids. |
60 | /// </summary> | 65 | /// </summary> |
61 | private IDictionary<UUID, bool> m_validUserUuids = new Dictionary<UUID, bool>(); | 66 | private IDictionary<UUID, bool> m_validUserUuids = new Dictionary<UUID, bool>(); |
62 | 67 | ||
63 | public ArchiveReadRequest(Scene scene, string loadPath) | 68 | public ArchiveReadRequest(Scene scene, string loadPath, bool merge) |
64 | { | 69 | { |
65 | m_scene = scene; | 70 | m_scene = scene; |
66 | m_loadStream = new GZipStream(GetStream(loadPath), CompressionMode.Decompress); | 71 | m_loadStream = new GZipStream(GetStream(loadPath), CompressionMode.Decompress); |
67 | m_errorMessage = String.Empty; | 72 | m_errorMessage = String.Empty; |
73 | m_merge = merge; | ||
68 | } | 74 | } |
69 | 75 | ||
70 | public ArchiveReadRequest(Scene scene, Stream loadStream) | 76 | public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge) |
71 | { | 77 | { |
72 | m_scene = scene; | 78 | m_scene = scene; |
73 | m_loadStream = loadStream; | 79 | m_loadStream = loadStream; |
80 | m_merge = merge; | ||
74 | } | 81 | } |
75 | 82 | ||
76 | /// <summary> | 83 | /// <summary> |
@@ -92,8 +99,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
92 | { | 99 | { |
93 | TarArchiveReader archive = new TarArchiveReader(m_loadStream); | 100 | TarArchiveReader archive = new TarArchiveReader(m_loadStream); |
94 | 101 | ||
95 | //AssetsDearchiver dearchiver = new AssetsDearchiver(m_scene.AssetCache); | ||
96 | |||
97 | string filePath = "ERROR"; | 102 | string filePath = "ERROR"; |
98 | 103 | ||
99 | byte[] data; | 104 | byte[] data; |
@@ -103,6 +108,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
103 | { | 108 | { |
104 | //m_log.DebugFormat( | 109 | //m_log.DebugFormat( |
105 | // "[ARCHIVER]: Successfully read {0} ({1} bytes)}", filePath, data.Length); | 110 | // "[ARCHIVER]: Successfully read {0} ({1} bytes)}", filePath, data.Length); |
111 | |||
106 | if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType) | 112 | if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType) |
107 | { | 113 | { |
108 | m_log.WarnFormat("[ARCHIVER]: Ignoring directory entry {0}", | 114 | m_log.WarnFormat("[ARCHIVER]: Ignoring directory entry {0}", |
@@ -112,11 +118,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
112 | { | 118 | { |
113 | serialisedSceneObjects.Add(m_asciiEncoding.GetString(data)); | 119 | serialisedSceneObjects.Add(m_asciiEncoding.GetString(data)); |
114 | } | 120 | } |
115 | // else if (filePath.Equals(ArchiveConstants.ASSETS_METADATA_PATH)) | ||
116 | // { | ||
117 | // string xml = m_asciiEncoding.GetString(data); | ||
118 | // dearchiver.AddAssetMetadata(xml); | ||
119 | // } | ||
120 | else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) | 121 | else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) |
121 | { | 122 | { |
122 | if (LoadAsset(filePath, data)) | 123 | if (LoadAsset(filePath, data)) |
@@ -124,11 +125,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
124 | else | 125 | else |
125 | failedAssetRestores++; | 126 | failedAssetRestores++; |
126 | } | 127 | } |
127 | else if (filePath.StartsWith(ArchiveConstants.TERRAINS_PATH)) | 128 | else if (!m_merge && filePath.StartsWith(ArchiveConstants.TERRAINS_PATH)) |
128 | { | 129 | { |
129 | LoadTerrain(filePath, data); | 130 | LoadTerrain(filePath, data); |
130 | } | 131 | } |
131 | else if (filePath.StartsWith(ArchiveConstants.SETTINGS_PATH)) | 132 | else if (!m_merge && filePath.StartsWith(ArchiveConstants.SETTINGS_PATH)) |
132 | { | 133 | { |
133 | LoadRegionSettings(filePath, data); | 134 | LoadRegionSettings(filePath, data); |
134 | } | 135 | } |
@@ -155,8 +156,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
155 | m_errorMessage += String.Format("Failed to load {0} assets", failedAssetRestores); | 156 | m_errorMessage += String.Format("Failed to load {0} assets", failedAssetRestores); |
156 | } | 157 | } |
157 | 158 | ||
158 | m_log.Info("[ARCHIVER]: Clearing all existing scene objects"); | 159 | if (!m_merge) |
159 | m_scene.DeleteAllSceneObjects(); | 160 | { |
161 | m_log.Info("[ARCHIVER]: Clearing all existing scene objects"); | ||
162 | m_scene.DeleteAllSceneObjects(); | ||
163 | } | ||
160 | 164 | ||
161 | // Reload serialized prims | 165 | // Reload serialized prims |
162 | m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects. Please wait.", serialisedSceneObjects.Count); | 166 | m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects. Please wait.", serialisedSceneObjects.Count); |
@@ -182,13 +186,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
182 | 186 | ||
183 | foreach (SceneObjectPart part in sceneObject.Children.Values) | 187 | foreach (SceneObjectPart part in sceneObject.Children.Values) |
184 | { | 188 | { |
185 | if (!resolveUserUuid(part.CreatorID)) | 189 | if (!ResolveUserUuid(part.CreatorID)) |
186 | part.CreatorID = masterAvatarId; | 190 | part.CreatorID = masterAvatarId; |
187 | 191 | ||
188 | if (!resolveUserUuid(part.OwnerID)) | 192 | if (!ResolveUserUuid(part.OwnerID)) |
189 | part.OwnerID = masterAvatarId; | 193 | part.OwnerID = masterAvatarId; |
190 | 194 | ||
191 | if (!resolveUserUuid(part.LastOwnerID)) | 195 | if (!ResolveUserUuid(part.LastOwnerID)) |
192 | part.LastOwnerID = masterAvatarId; | 196 | part.LastOwnerID = masterAvatarId; |
193 | 197 | ||
194 | // And zap any troublesome sit target information | 198 | // And zap any troublesome sit target information |
@@ -201,11 +205,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
201 | TaskInventoryDictionary inv = part.TaskInventory; | 205 | TaskInventoryDictionary inv = part.TaskInventory; |
202 | foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv) | 206 | foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv) |
203 | { | 207 | { |
204 | if (!resolveUserUuid(kvp.Value.OwnerID)) | 208 | if (!ResolveUserUuid(kvp.Value.OwnerID)) |
205 | { | 209 | { |
206 | kvp.Value.OwnerID = masterAvatarId; | 210 | kvp.Value.OwnerID = masterAvatarId; |
207 | } | 211 | } |
208 | if (!resolveUserUuid(kvp.Value.CreatorID)) | 212 | if (!ResolveUserUuid(kvp.Value.CreatorID)) |
209 | { | 213 | { |
210 | kvp.Value.CreatorID = masterAvatarId; | 214 | kvp.Value.CreatorID = masterAvatarId; |
211 | } | 215 | } |
@@ -242,7 +246,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
242 | /// </summary> | 246 | /// </summary> |
243 | /// <param name="uuid"></param> | 247 | /// <param name="uuid"></param> |
244 | /// <returns></returns> | 248 | /// <returns></returns> |
245 | private bool resolveUserUuid(UUID uuid) | 249 | private bool ResolveUserUuid(UUID uuid) |
246 | { | 250 | { |
247 | if (!m_validUserUuids.ContainsKey(uuid)) | 251 | if (!m_validUserUuids.ContainsKey(uuid)) |
248 | { | 252 | { |