diff options
Merge branch 'master' into diva-textures
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver')
5 files changed, 113 insertions, 73 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 907e2d4..f761bf0 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |||
@@ -59,7 +59,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
59 | /// <value> | 59 | /// <value> |
60 | /// We only use this to request modules | 60 | /// We only use this to request modules |
61 | /// </value> | 61 | /// </value> |
62 | protected Scene m_scene; | 62 | protected Scene m_scene; |
63 | 63 | ||
64 | /// <value> | 64 | /// <value> |
65 | /// The stream from which the inventory archive will be loaded. | 65 | /// The stream from which the inventory archive will be loaded. |
@@ -186,7 +186,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
186 | item.Folder = foundFolder.ID; | 186 | item.Folder = foundFolder.ID; |
187 | 187 | ||
188 | //m_userInfo.AddItem(item); | 188 | //m_userInfo.AddItem(item); |
189 | m_scene.InventoryService.AddItem(item); | 189 | m_scene.InventoryService.AddItem(item); |
190 | successfulItemRestores++; | 190 | successfulItemRestores++; |
191 | 191 | ||
192 | // If we're loading an item directly into the given destination folder then we need to record | 192 | // If we're loading an item directly into the given destination folder then we need to record |
@@ -299,14 +299,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
299 | = new InventoryFolderBase( | 299 | = new InventoryFolderBase( |
300 | newFolderId, newFolderName, m_userInfo.UserProfile.ID, | 300 | newFolderId, newFolderName, m_userInfo.UserProfile.ID, |
301 | (short)AssetType.Unknown, destFolder.ID, 1); | 301 | (short)AssetType.Unknown, destFolder.ID, 1); |
302 | m_scene.InventoryService.AddFolder(destFolder); | 302 | m_scene.InventoryService.AddFolder(destFolder); |
303 | 303 | ||
304 | // UUID newFolderId = UUID.Random(); | 304 | // UUID newFolderId = UUID.Random(); |
305 | // m_scene.InventoryService.AddFolder( | 305 | // m_scene.InventoryService.AddFolder( |
306 | // m_userInfo.CreateFolder( | 306 | // m_userInfo.CreateFolder( |
307 | // folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID); | 307 | // folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID); |
308 | 308 | ||
309 | // m_log.DebugFormat("[INVENTORY ARCHIVER]: Retrieving newly created folder {0}", folderName); | 309 | // m_log.DebugFormat("[INVENTORY ARCHIVER]: Retrieving newly created folder {0}", folderName); |
310 | // foundFolder = foundFolder.GetChildFolder(newFolderId); | 310 | // foundFolder = foundFolder.GetChildFolder(newFolderId); |
311 | // m_log.DebugFormat( | 311 | // m_log.DebugFormat( |
312 | // "[INVENTORY ARCHIVER]: Retrieved newly created folder {0} with ID {1}", | 312 | // "[INVENTORY ARCHIVER]: Retrieved newly created folder {0} with ID {1}", |
@@ -321,7 +321,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
321 | nodesLoaded.Add(destFolder); | 321 | nodesLoaded.Add(destFolder); |
322 | 322 | ||
323 | i++; | 323 | i++; |
324 | } | 324 | } |
325 | 325 | ||
326 | return destFolder; | 326 | return destFolder; |
327 | 327 | ||
@@ -357,7 +357,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
357 | rawFolders[i++], newFolderId, (ushort)AssetType.Folder, foundFolder.ID); | 357 | rawFolders[i++], newFolderId, (ushort)AssetType.Folder, foundFolder.ID); |
358 | foundFolder = foundFolder.GetChildFolder(newFolderId); | 358 | foundFolder = foundFolder.GetChildFolder(newFolderId); |
359 | } | 359 | } |
360 | */ | 360 | */ |
361 | } | 361 | } |
362 | 362 | ||
363 | /// <summary> | 363 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs index 5ebf2fa..a822d10 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs | |||
@@ -42,7 +42,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
42 | 42 | ||
43 | /// <summary> | 43 | /// <summary> |
44 | /// Find a folder given a PATH_DELIMITER delimited path starting from a user's root folder | 44 | /// Find a folder given a PATH_DELIMITER delimited path starting from a user's root folder |
45 | /// </summary> | 45 | /// </summary> |
46 | /// | 46 | /// |
47 | /// This method does not handle paths that contain multiple delimitors | 47 | /// This method does not handle paths that contain multiple delimitors |
48 | /// | 48 | /// |
@@ -58,7 +58,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
58 | /// User id to search | 58 | /// User id to search |
59 | /// </param> | 59 | /// </param> |
60 | /// <param name="path"> | 60 | /// <param name="path"> |
61 | /// The path to the required folder. | 61 | /// The path to the required folder. |
62 | /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned. | 62 | /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned. |
63 | /// </param> | 63 | /// </param> |
64 | /// <returns>null if the folder is not found</returns> | 64 | /// <returns>null if the folder is not found</returns> |
@@ -71,11 +71,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
71 | return null; | 71 | return null; |
72 | 72 | ||
73 | return FindFolderByPath(inventoryService, rootFolder, path); | 73 | return FindFolderByPath(inventoryService, rootFolder, path); |
74 | } | 74 | } |
75 | 75 | ||
76 | /// <summary> | 76 | /// <summary> |
77 | /// Find a folder given a PATH_DELIMITER delimited path starting from this folder | 77 | /// Find a folder given a PATH_DELIMITER delimited path starting from this folder |
78 | /// </summary> | 78 | /// </summary> |
79 | /// | 79 | /// |
80 | /// This method does not handle paths that contain multiple delimitors | 80 | /// This method does not handle paths that contain multiple delimitors |
81 | /// | 81 | /// |
@@ -91,7 +91,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
91 | /// The folder from which the path starts | 91 | /// The folder from which the path starts |
92 | /// </param> | 92 | /// </param> |
93 | /// <param name="path"> | 93 | /// <param name="path"> |
94 | /// The path to the required folder. | 94 | /// The path to the required folder. |
95 | /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned. | 95 | /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned. |
96 | /// </param> | 96 | /// </param> |
97 | /// <returns>null if the folder is not found</returns> | 97 | /// <returns>null if the folder is not found</returns> |
@@ -154,7 +154,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
154 | return null; | 154 | return null; |
155 | 155 | ||
156 | return FindItemByPath(inventoryService, rootFolder, path); | 156 | return FindItemByPath(inventoryService, rootFolder, path); |
157 | } | 157 | } |
158 | 158 | ||
159 | /// <summary> | 159 | /// <summary> |
160 | /// Find an item given a PATH_DELIMITOR delimited path starting from this folder. | 160 | /// Find an item given a PATH_DELIMITOR delimited path starting from this folder. |
@@ -194,7 +194,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
194 | } | 194 | } |
195 | else | 195 | else |
196 | { | 196 | { |
197 | InventoryCollection contents = inventoryService.GetFolderContent(startFolder.Owner, startFolder.ID); | 197 | InventoryCollection contents = inventoryService.GetFolderContent(startFolder.Owner, startFolder.ID); |
198 | 198 | ||
199 | foreach (InventoryFolderBase folder in contents.Folders) | 199 | foreach (InventoryFolderBase folder in contents.Folders) |
200 | { | 200 | { |
@@ -205,6 +205,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
205 | 205 | ||
206 | // We didn't find an item or intermediate folder with the given name | 206 | // We didn't find an item or intermediate folder with the given name |
207 | return null; | 207 | return null; |
208 | } | 208 | } |
209 | } | 209 | } |
210 | } \ No newline at end of file | 210 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 7b4a9eb..499c552 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | |||
@@ -55,7 +55,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
55 | 55 | ||
56 | private InventoryArchiverModule m_module; | 56 | private InventoryArchiverModule m_module; |
57 | private CachedUserInfo m_userInfo; | 57 | private CachedUserInfo m_userInfo; |
58 | private string m_invPath; | 58 | private string m_invPath; |
59 | protected TarArchiveWriter m_archiveWriter; | 59 | protected TarArchiveWriter m_archiveWriter; |
60 | protected UuidGatherer m_assetGatherer; | 60 | protected UuidGatherer m_assetGatherer; |
61 | 61 | ||
@@ -118,6 +118,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
118 | 118 | ||
119 | protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids) | 119 | protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids) |
120 | { | 120 | { |
121 | // We're almost done. Just need to write out the control file now | ||
122 | m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p1ControlFile()); | ||
123 | m_log.InfoFormat("[ARCHIVER]: Added control file to archive."); | ||
124 | |||
121 | Exception reportedException = null; | 125 | Exception reportedException = null; |
122 | bool succeeded = true; | 126 | bool succeeded = true; |
123 | 127 | ||
@@ -164,7 +168,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
164 | { | 168 | { |
165 | path += CreateArchiveFolderName(inventoryFolder); | 169 | path += CreateArchiveFolderName(inventoryFolder); |
166 | 170 | ||
167 | // We need to make sure that we record empty folders | 171 | // We need to make sure that we record empty folders |
168 | m_archiveWriter.WriteDir(path); | 172 | m_archiveWriter.WriteDir(path); |
169 | } | 173 | } |
170 | 174 | ||
@@ -258,7 +262,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
258 | if (maxComponentIndex >= 0 && components[maxComponentIndex] == STAR_WILDCARD) | 262 | if (maxComponentIndex >= 0 && components[maxComponentIndex] == STAR_WILDCARD) |
259 | { | 263 | { |
260 | foundStar = true; | 264 | foundStar = true; |
261 | maxComponentIndex--; | 265 | maxComponentIndex--; |
262 | } | 266 | } |
263 | 267 | ||
264 | m_invPath = String.Empty; | 268 | m_invPath = String.Empty; |
@@ -320,7 +324,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
320 | SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !foundStar); | 324 | SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !foundStar); |
321 | } | 325 | } |
322 | 326 | ||
323 | SaveUsers(); | 327 | // Don't put all this profile information into the archive right now. |
328 | //SaveUsers(); | ||
329 | |||
324 | new AssetsRequest( | 330 | new AssetsRequest( |
325 | new AssetsArchiver(m_archiveWriter), m_assetUuids.Keys, | 331 | new AssetsArchiver(m_archiveWriter), m_assetUuids.Keys, |
326 | m_scene.AssetService, ReceivedAllAssets).Execute(); | 332 | m_scene.AssetService, ReceivedAllAssets).Execute(); |
@@ -363,8 +369,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
363 | /// <returns></returns> | 369 | /// <returns></returns> |
364 | public static string CreateArchiveFolderName(InventoryFolderBase folder) | 370 | public static string CreateArchiveFolderName(InventoryFolderBase folder) |
365 | { | 371 | { |
366 | return CreateArchiveFolderName(folder.Name, folder.ID); | 372 | return CreateArchiveFolderName(folder.Name, folder.ID); |
367 | } | 373 | } |
368 | 374 | ||
369 | /// <summary> | 375 | /// <summary> |
370 | /// Create the archive name for a particular item. | 376 | /// Create the archive name for a particular item. |
@@ -377,7 +383,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
377 | /// <returns></returns> | 383 | /// <returns></returns> |
378 | public static string CreateArchiveItemName(InventoryItemBase item) | 384 | public static string CreateArchiveItemName(InventoryItemBase item) |
379 | { | 385 | { |
380 | return CreateArchiveItemName(item.Name, item.ID); | 386 | return CreateArchiveItemName(item.Name, item.ID); |
381 | } | 387 | } |
382 | 388 | ||
383 | /// <summary> | 389 | /// <summary> |
@@ -392,7 +398,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
392 | "{0}{1}{2}/", | 398 | "{0}{1}{2}/", |
393 | name, | 399 | name, |
394 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, | 400 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, |
395 | id); | 401 | id); |
396 | } | 402 | } |
397 | 403 | ||
398 | /// <summary> | 404 | /// <summary> |
@@ -400,14 +406,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
400 | /// </summary> | 406 | /// </summary> |
401 | /// <param name="name"></param> | 407 | /// <param name="name"></param> |
402 | /// <param name="id"></param> | 408 | /// <param name="id"></param> |
403 | /// <returns></returns> | 409 | /// <returns></returns> |
404 | public static string CreateArchiveItemName(string name, UUID id) | 410 | public static string CreateArchiveItemName(string name, UUID id) |
405 | { | 411 | { |
406 | return string.Format( | 412 | return string.Format( |
407 | "{0}{1}{2}.xml", | 413 | "{0}{1}{2}.xml", |
408 | name, | 414 | name, |
409 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, | 415 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, |
410 | id); | 416 | id); |
417 | } | ||
418 | |||
419 | /// <summary> | ||
420 | /// Create the control file for a 0.1 version archive | ||
421 | /// </summary> | ||
422 | /// <returns></returns> | ||
423 | public static string Create0p1ControlFile() | ||
424 | { | ||
425 | StringWriter sw = new StringWriter(); | ||
426 | XmlTextWriter xtw = new XmlTextWriter(sw); | ||
427 | xtw.Formatting = Formatting.Indented; | ||
428 | xtw.WriteStartDocument(); | ||
429 | xtw.WriteStartElement("archive"); | ||
430 | xtw.WriteAttributeString("major_version", "0"); | ||
431 | xtw.WriteAttributeString("minor_version", "1"); | ||
432 | xtw.WriteEndElement(); | ||
433 | |||
434 | xtw.Flush(); | ||
435 | xtw.Close(); | ||
436 | |||
437 | String s = sw.ToString(); | ||
438 | sw.Close(); | ||
439 | |||
440 | return s; | ||
411 | } | 441 | } |
412 | } | 442 | } |
413 | } \ No newline at end of file | 443 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 9f49da9..1228eb1 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | |||
@@ -40,12 +40,12 @@ using OpenSim.Region.Framework.Scenes; | |||
40 | using OpenSim.Services.Interfaces; | 40 | using OpenSim.Services.Interfaces; |
41 | 41 | ||
42 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | 42 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver |
43 | { | 43 | { |
44 | /// <summary> | 44 | /// <summary> |
45 | /// This module loads and saves OpenSimulator inventory archives | 45 | /// This module loads and saves OpenSimulator inventory archives |
46 | /// </summary> | 46 | /// </summary> |
47 | public class InventoryArchiverModule : IRegionModule, IInventoryArchiverModule | 47 | public class InventoryArchiverModule : IRegionModule, IInventoryArchiverModule |
48 | { | 48 | { |
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
50 | 50 | ||
51 | public string Name { get { return "Inventory Archiver Module"; } } | 51 | public string Name { get { return "Inventory Archiver Module"; } } |
@@ -57,7 +57,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
57 | /// </value> | 57 | /// </value> |
58 | public bool DisablePresenceChecks { get; set; } | 58 | public bool DisablePresenceChecks { get; set; } |
59 | 59 | ||
60 | public event InventoryArchiveSaved OnInventoryArchiveSaved; | 60 | public event InventoryArchiveSaved OnInventoryArchiveSaved; |
61 | 61 | ||
62 | /// <summary> | 62 | /// <summary> |
63 | /// The file to load and save inventory if no filename has been specified | 63 | /// The file to load and save inventory if no filename has been specified |
@@ -83,7 +83,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
83 | } | 83 | } |
84 | 84 | ||
85 | public void Initialise(Scene scene, IConfigSource source) | 85 | public void Initialise(Scene scene, IConfigSource source) |
86 | { | 86 | { |
87 | if (m_scenes.Count == 0) | 87 | if (m_scenes.Count == 0) |
88 | { | 88 | { |
89 | scene.RegisterModuleInterface<IInventoryArchiverModule>(this); | 89 | scene.RegisterModuleInterface<IInventoryArchiverModule>(this); |
@@ -102,7 +102,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
102 | m_aScene = scene; | 102 | m_aScene = scene; |
103 | } | 103 | } |
104 | 104 | ||
105 | m_scenes[scene.RegionInfo.RegionID] = scene; | 105 | m_scenes[scene.RegionInfo.RegionID] = scene; |
106 | } | 106 | } |
107 | 107 | ||
108 | public void PostInitialise() {} | 108 | public void PostInitialise() {} |
@@ -119,7 +119,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
119 | InventoryArchiveSaved handlerInventoryArchiveSaved = OnInventoryArchiveSaved; | 119 | InventoryArchiveSaved handlerInventoryArchiveSaved = OnInventoryArchiveSaved; |
120 | if (handlerInventoryArchiveSaved != null) | 120 | if (handlerInventoryArchiveSaved != null) |
121 | handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException); | 121 | handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException); |
122 | } | 122 | } |
123 | 123 | ||
124 | public bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream) | 124 | public bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream) |
125 | { | 125 | { |
@@ -174,7 +174,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
174 | public bool DearchiveInventory(string firstName, string lastName, string invPath, string pass, Stream loadStream) | 174 | public bool DearchiveInventory(string firstName, string lastName, string invPath, string pass, Stream loadStream) |
175 | { | 175 | { |
176 | if (m_scenes.Count > 0) | 176 | if (m_scenes.Count > 0) |
177 | { | 177 | { |
178 | CachedUserInfo userInfo = GetUserInfo(firstName, lastName, pass); | 178 | CachedUserInfo userInfo = GetUserInfo(firstName, lastName, pass); |
179 | 179 | ||
180 | if (userInfo != null) | 180 | if (userInfo != null) |
@@ -182,7 +182,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
182 | if (CheckPresence(userInfo.UserProfile.ID)) | 182 | if (CheckPresence(userInfo.UserProfile.ID)) |
183 | { | 183 | { |
184 | InventoryArchiveReadRequest request = | 184 | InventoryArchiveReadRequest request = |
185 | new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream); | 185 | new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream); |
186 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); | 186 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); |
187 | 187 | ||
188 | return true; | 188 | return true; |
@@ -197,12 +197,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
197 | } | 197 | } |
198 | 198 | ||
199 | return false; | 199 | return false; |
200 | } | 200 | } |
201 | 201 | ||
202 | public bool DearchiveInventory(string firstName, string lastName, string invPath, string pass, string loadPath) | 202 | public bool DearchiveInventory(string firstName, string lastName, string invPath, string pass, string loadPath) |
203 | { | 203 | { |
204 | if (m_scenes.Count > 0) | 204 | if (m_scenes.Count > 0) |
205 | { | 205 | { |
206 | CachedUserInfo userInfo = GetUserInfo(firstName, lastName, pass); | 206 | CachedUserInfo userInfo = GetUserInfo(firstName, lastName, pass); |
207 | 207 | ||
208 | if (userInfo != null) | 208 | if (userInfo != null) |
@@ -210,7 +210,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
210 | if (CheckPresence(userInfo.UserProfile.ID)) | 210 | if (CheckPresence(userInfo.UserProfile.ID)) |
211 | { | 211 | { |
212 | InventoryArchiveReadRequest request = | 212 | InventoryArchiveReadRequest request = |
213 | new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath); | 213 | new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath); |
214 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); | 214 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); |
215 | 215 | ||
216 | return true; | 216 | return true; |
@@ -221,11 +221,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
221 | "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator", | 221 | "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator", |
222 | userInfo.UserProfile.Name, userInfo.UserProfile.ID); | 222 | userInfo.UserProfile.Name, userInfo.UserProfile.ID); |
223 | } | 223 | } |
224 | } | 224 | } |
225 | } | 225 | } |
226 | 226 | ||
227 | return false; | 227 | return false; |
228 | } | 228 | } |
229 | 229 | ||
230 | /// <summary> | 230 | /// <summary> |
231 | /// Load inventory from an inventory file archive | 231 | /// Load inventory from an inventory file archive |
@@ -252,7 +252,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
252 | "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}", | 252 | "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}", |
253 | loadPath, invPath, firstName, lastName); | 253 | loadPath, invPath, firstName, lastName); |
254 | 254 | ||
255 | if (DearchiveInventory(firstName, lastName, invPath, pass, loadPath)) | 255 | if (DearchiveInventory(firstName, lastName, invPath, pass, loadPath)) |
256 | m_log.InfoFormat( | 256 | m_log.InfoFormat( |
257 | "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}", | 257 | "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}", |
258 | loadPath, firstName, lastName); | 258 | loadPath, firstName, lastName); |
@@ -264,7 +264,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
264 | /// <param name="cmdparams"></param> | 264 | /// <param name="cmdparams"></param> |
265 | protected void HandleSaveInvConsoleCommand(string module, string[] cmdparams) | 265 | protected void HandleSaveInvConsoleCommand(string module, string[] cmdparams) |
266 | { | 266 | { |
267 | if (cmdparams.Length < 5) | 267 | if (cmdparams.Length < 6) |
268 | { | 268 | { |
269 | m_log.Error( | 269 | m_log.Error( |
270 | "[INVENTORY ARCHIVER]: usage is save iar <first name> <last name> <inventory path> <user password> [<save file path>]"); | 270 | "[INVENTORY ARCHIVER]: usage is save iar <first name> <last name> <inventory path> <user password> [<save file path>]"); |
@@ -288,7 +288,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
288 | 288 | ||
289 | lock (m_pendingConsoleSaves) | 289 | lock (m_pendingConsoleSaves) |
290 | m_pendingConsoleSaves.Add(id); | 290 | m_pendingConsoleSaves.Add(id); |
291 | } | 291 | } |
292 | 292 | ||
293 | private void SaveInvConsoleCommandCompleted( | 293 | private void SaveInvConsoleCommandCompleted( |
294 | Guid id, bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, | 294 | Guid id, bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, |
@@ -324,6 +324,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
324 | protected CachedUserInfo GetUserInfo(string firstName, string lastName, string pass) | 324 | protected CachedUserInfo GetUserInfo(string firstName, string lastName, string pass) |
325 | { | 325 | { |
326 | CachedUserInfo userInfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); | 326 | CachedUserInfo userInfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); |
327 | //m_aScene.CommsManager.UserService.GetUserProfile(firstName, lastName); | ||
327 | if (null == userInfo) | 328 | if (null == userInfo) |
328 | { | 329 | { |
329 | m_log.ErrorFormat( | 330 | m_log.ErrorFormat( |
@@ -332,16 +333,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
332 | return null; | 333 | return null; |
333 | } | 334 | } |
334 | 335 | ||
335 | string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(pass) + ":" + userInfo.UserProfile.PasswordSalt); | 336 | try |
336 | if (userInfo.UserProfile.PasswordHash != md5PasswdHash) | ||
337 | { | 337 | { |
338 | m_log.ErrorFormat( | 338 | if (m_aScene.CommsManager.UserService.AuthenticateUserByPassword(userInfo.UserProfile.ID, pass)) |
339 | "[INVENTORY ARCHIVER]: Password for user {0} {1} incorrect. Please try again.", | 339 | { |
340 | firstName, lastName); | 340 | return userInfo; |
341 | } | ||
342 | else | ||
343 | { | ||
344 | m_log.ErrorFormat( | ||
345 | "[INVENTORY ARCHIVER]: Password for user {0} {1} incorrect. Please try again.", | ||
346 | firstName, lastName); | ||
347 | return null; | ||
348 | } | ||
349 | } | ||
350 | catch (Exception e) | ||
351 | { | ||
352 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: Could not authenticate password, {0}", e.Message); | ||
341 | return null; | 353 | return null; |
342 | } | 354 | } |
343 | |||
344 | return userInfo; | ||
345 | } | 355 | } |
346 | 356 | ||
347 | /// <summary> | 357 | /// <summary> |
@@ -349,7 +359,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
349 | /// </summary> | 359 | /// </summary> |
350 | /// <param name="loadedNodes">Can be empty. In which case, nothing happens</param> | 360 | /// <param name="loadedNodes">Can be empty. In which case, nothing happens</param> |
351 | private void UpdateClientWithLoadedNodes(CachedUserInfo userInfo, List<InventoryNodeBase> loadedNodes) | 361 | private void UpdateClientWithLoadedNodes(CachedUserInfo userInfo, List<InventoryNodeBase> loadedNodes) |
352 | { | 362 | { |
353 | if (loadedNodes.Count == 0) | 363 | if (loadedNodes.Count == 0) |
354 | return; | 364 | return; |
355 | 365 | ||
@@ -358,19 +368,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
358 | ScenePresence user = scene.GetScenePresence(userInfo.UserProfile.ID); | 368 | ScenePresence user = scene.GetScenePresence(userInfo.UserProfile.ID); |
359 | 369 | ||
360 | if (user != null && !user.IsChildAgent) | 370 | if (user != null && !user.IsChildAgent) |
361 | { | 371 | { |
362 | foreach (InventoryNodeBase node in loadedNodes) | 372 | foreach (InventoryNodeBase node in loadedNodes) |
363 | { | 373 | { |
364 | m_log.DebugFormat( | 374 | // m_log.DebugFormat( |
365 | "[INVENTORY ARCHIVER]: Notifying {0} of loaded inventory node {1}", | 375 | // "[INVENTORY ARCHIVER]: Notifying {0} of loaded inventory node {1}", |
366 | user.Name, node.Name); | 376 | // user.Name, node.Name); |
367 | 377 | ||
368 | user.ControllingClient.SendBulkUpdateInventory(node); | 378 | user.ControllingClient.SendBulkUpdateInventory(node); |
369 | } | 379 | } |
370 | 380 | ||
371 | break; | 381 | break; |
372 | } | 382 | } |
373 | } | 383 | } |
374 | } | 384 | } |
375 | 385 | ||
376 | /// <summary> | 386 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index ed293cd..b0fdcd6 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -37,7 +37,7 @@ using OpenMetaverse; | |||
37 | using OpenSim.Data; | 37 | using OpenSim.Data; |
38 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using OpenSim.Framework.Serialization; | 39 | using OpenSim.Framework.Serialization; |
40 | using OpenSim.Framework.Serialization.External; | 40 | using OpenSim.Framework.Serialization.External; |
41 | using OpenSim.Framework.Communications; | 41 | using OpenSim.Framework.Communications; |
42 | using OpenSim.Framework.Communications.Cache; | 42 | using OpenSim.Framework.Communications.Cache; |
43 | using OpenSim.Framework.Communications.Osp; | 43 | using OpenSim.Framework.Communications.Osp; |
@@ -70,7 +70,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
70 | Exception reportedException) | 70 | Exception reportedException) |
71 | { | 71 | { |
72 | mre.Set(); | 72 | mre.Set(); |
73 | } | 73 | } |
74 | 74 | ||
75 | /// <summary> | 75 | /// <summary> |
76 | /// Test saving a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet). | 76 | /// Test saving a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet). |
@@ -157,7 +157,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
157 | string expectedObject1FilePath = string.Format( | 157 | string expectedObject1FilePath = string.Format( |
158 | "{0}{1}{2}", | 158 | "{0}{1}{2}", |
159 | ArchiveConstants.INVENTORY_PATH, | 159 | ArchiveConstants.INVENTORY_PATH, |
160 | InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder), | 160 | InventoryArchiveWriteRequest.CreateArchiveFolderName(objsFolder), |
161 | expectedObject1FileName); | 161 | expectedObject1FileName); |
162 | 162 | ||
163 | string filePath; | 163 | string filePath; |
@@ -195,7 +195,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
195 | Assert.That(gotObject1File, Is.True, "No item1 file in archive"); | 195 | Assert.That(gotObject1File, Is.True, "No item1 file in archive"); |
196 | // Assert.That(gotObject2File, Is.True, "No object2 file in archive"); | 196 | // Assert.That(gotObject2File, Is.True, "No object2 file in archive"); |
197 | 197 | ||
198 | // TODO: Test presence of more files and contents of files. | 198 | // TODO: Test presence of more files and contents of files. |
199 | } | 199 | } |
200 | 200 | ||
201 | /// <summary> | 201 | /// <summary> |
@@ -206,7 +206,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
206 | /// This test also does some deeper probing of loading into nested inventory structures | 206 | /// This test also does some deeper probing of loading into nested inventory structures |
207 | [Test] | 207 | [Test] |
208 | public void TestLoadIarV0_1ExistingUsers() | 208 | public void TestLoadIarV0_1ExistingUsers() |
209 | { | 209 | { |
210 | TestHelper.InMethod(); | 210 | TestHelper.InMethod(); |
211 | 211 | ||
212 | //log4net.Config.XmlConfigurator.Configure(); | 212 | //log4net.Config.XmlConfigurator.Configure(); |
@@ -238,7 +238,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
238 | tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1)); | 238 | tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1)); |
239 | tar.Close(); | 239 | tar.Close(); |
240 | 240 | ||
241 | MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); | 241 | MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); |
242 | SerialiserModule serialiserModule = new SerialiserModule(); | 242 | SerialiserModule serialiserModule = new SerialiserModule(); |
243 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); | 243 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); |
244 | 244 | ||
@@ -271,9 +271,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
271 | Assert.That(foundItem1.Owner, Is.EqualTo(userUuid), | 271 | Assert.That(foundItem1.Owner, Is.EqualTo(userUuid), |
272 | "Loaded item owner doesn't match inventory reciever"); | 272 | "Loaded item owner doesn't match inventory reciever"); |
273 | 273 | ||
274 | // Now try loading to a root child folder | 274 | // Now try loading to a root child folder |
275 | UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userInfo.UserProfile.ID, "xA"); | 275 | UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userInfo.UserProfile.ID, "xA"); |
276 | archiveReadStream = new MemoryStream(archiveReadStream.ToArray()); | 276 | archiveReadStream = new MemoryStream(archiveReadStream.ToArray()); |
277 | archiverModule.DearchiveInventory(userFirstName, userLastName, "xA", "meowfood", archiveReadStream); | 277 | archiverModule.DearchiveInventory(userFirstName, userLastName, "xA", "meowfood", archiveReadStream); |
278 | 278 | ||
279 | InventoryItemBase foundItem2 | 279 | InventoryItemBase foundItem2 |
@@ -282,12 +282,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
282 | 282 | ||
283 | // Now try loading to a more deeply nested folder | 283 | // Now try loading to a more deeply nested folder |
284 | UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC"); | 284 | UserInventoryTestUtils.CreateInventoryFolder(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC"); |
285 | archiveReadStream = new MemoryStream(archiveReadStream.ToArray()); | 285 | archiveReadStream = new MemoryStream(archiveReadStream.ToArray()); |
286 | archiverModule.DearchiveInventory(userFirstName, userLastName, "xB/xC", "meowfood", archiveReadStream); | 286 | archiverModule.DearchiveInventory(userFirstName, userLastName, "xB/xC", "meowfood", archiveReadStream); |
287 | 287 | ||
288 | InventoryItemBase foundItem3 | 288 | InventoryItemBase foundItem3 |
289 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC/" + itemName); | 289 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, "xB/xC/" + itemName); |
290 | Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3"); | 290 | Assert.That(foundItem3, Is.Not.Null, "Didn't find loaded item 3"); |
291 | } | 291 | } |
292 | 292 | ||
293 | /// <summary> | 293 | /// <summary> |
@@ -299,7 +299,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
299 | /// (as tested in the a later commented out test) | 299 | /// (as tested in the a later commented out test) |
300 | [Test] | 300 | [Test] |
301 | public void TestLoadIarV0_1AbsentUsers() | 301 | public void TestLoadIarV0_1AbsentUsers() |
302 | { | 302 | { |
303 | TestHelper.InMethod(); | 303 | TestHelper.InMethod(); |
304 | 304 | ||
305 | log4net.Config.XmlConfigurator.Configure(); | 305 | log4net.Config.XmlConfigurator.Configure(); |
@@ -331,7 +331,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
331 | tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1)); | 331 | tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1)); |
332 | tar.Close(); | 332 | tar.Close(); |
333 | 333 | ||
334 | MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); | 334 | MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); |
335 | SerialiserModule serialiserModule = new SerialiserModule(); | 335 | SerialiserModule serialiserModule = new SerialiserModule(); |
336 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); | 336 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); |
337 | 337 | ||
@@ -357,8 +357,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
357 | // "Loaded item non-uuid creator doesn't match that of the loading user"); | 357 | // "Loaded item non-uuid creator doesn't match that of the loading user"); |
358 | Assert.That( | 358 | Assert.That( |
359 | foundItem1.CreatorIdAsUuid, Is.EqualTo(userUuid), | 359 | foundItem1.CreatorIdAsUuid, Is.EqualTo(userUuid), |
360 | "Loaded item uuid creator doesn't match that of the loading user"); | 360 | "Loaded item uuid creator doesn't match that of the loading user"); |
361 | } | 361 | } |
362 | 362 | ||
363 | /// <summary> | 363 | /// <summary> |
364 | /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where | 364 | /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet) where |
@@ -367,7 +367,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
367 | /// Disabled since temporary profiles have not yet been implemented. | 367 | /// Disabled since temporary profiles have not yet been implemented. |
368 | //[Test] | 368 | //[Test] |
369 | public void TestLoadIarV0_1TempProfiles() | 369 | public void TestLoadIarV0_1TempProfiles() |
370 | { | 370 | { |
371 | TestHelper.InMethod(); | 371 | TestHelper.InMethod(); |
372 | 372 | ||
373 | log4net.Config.XmlConfigurator.Configure(); | 373 | log4net.Config.XmlConfigurator.Configure(); |
@@ -396,7 +396,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
396 | tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1)); | 396 | tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1)); |
397 | tar.Close(); | 397 | tar.Close(); |
398 | 398 | ||
399 | MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); | 399 | MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); |
400 | SerialiserModule serialiserModule = new SerialiserModule(); | 400 | SerialiserModule serialiserModule = new SerialiserModule(); |
401 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); | 401 | InventoryArchiverModule archiverModule = new InventoryArchiverModule(true); |
402 | 402 | ||
@@ -436,7 +436,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
436 | Assert.That(foundItem.Owner, Is.EqualTo(userUuid)); | 436 | Assert.That(foundItem.Owner, Is.EqualTo(userUuid)); |
437 | 437 | ||
438 | Console.WriteLine("### Successfully completed {0} ###", MethodBase.GetCurrentMethod()); | 438 | Console.WriteLine("### Successfully completed {0} ###", MethodBase.GetCurrentMethod()); |
439 | } | 439 | } |
440 | 440 | ||
441 | /// <summary> | 441 | /// <summary> |
442 | /// Test replication of an archive path to the user's inventory. | 442 | /// Test replication of an archive path to the user's inventory. |
@@ -474,7 +474,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
474 | string itemArchivePath | 474 | string itemArchivePath |
475 | = string.Format( | 475 | = string.Format( |
476 | "{0}{1}{2}{3}", | 476 | "{0}{1}{2}{3}", |
477 | ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName); | 477 | ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemArchiveName); |
478 | 478 | ||
479 | //Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder); | 479 | //Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder); |
480 | 480 | ||