diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | 106 |
1 files changed, 76 insertions, 30 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 849449b..8847414 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | |||
@@ -34,7 +34,6 @@ using NDesk.Options; | |||
34 | using Nini.Config; | 34 | using Nini.Config; |
35 | using OpenMetaverse; | 35 | using OpenMetaverse; |
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Communications; | ||
38 | using OpenSim.Framework.Console; | 37 | using OpenSim.Framework.Console; |
39 | using OpenSim.Region.Framework.Interfaces; | 38 | using OpenSim.Region.Framework.Interfaces; |
40 | using OpenSim.Region.Framework.Scenes; | 39 | using OpenSim.Region.Framework.Scenes; |
@@ -57,6 +56,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
57 | // public bool DisablePresenceChecks { get; set; } | 56 | // public bool DisablePresenceChecks { get; set; } |
58 | 57 | ||
59 | public event InventoryArchiveSaved OnInventoryArchiveSaved; | 58 | public event InventoryArchiveSaved OnInventoryArchiveSaved; |
59 | public event InventoryArchiveLoaded OnInventoryArchiveLoaded; | ||
60 | 60 | ||
61 | /// <summary> | 61 | /// <summary> |
62 | /// The file to load and save inventory if no filename has been specified | 62 | /// The file to load and save inventory if no filename has been specified |
@@ -64,9 +64,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
64 | protected const string DEFAULT_INV_BACKUP_FILENAME = "user-inventory.iar"; | 64 | protected const string DEFAULT_INV_BACKUP_FILENAME = "user-inventory.iar"; |
65 | 65 | ||
66 | /// <value> | 66 | /// <value> |
67 | /// Pending save completions initiated from the console | 67 | /// Pending save and load completions initiated from the console |
68 | /// </value> | 68 | /// </value> |
69 | protected List<Guid> m_pendingConsoleSaves = new List<Guid>(); | 69 | protected List<UUID> m_pendingConsoleTasks = new List<UUID>(); |
70 | 70 | ||
71 | /// <value> | 71 | /// <value> |
72 | /// All scenes that this module knows about | 72 | /// All scenes that this module knows about |
@@ -111,6 +111,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
111 | { | 111 | { |
112 | scene.RegisterModuleInterface<IInventoryArchiverModule>(this); | 112 | scene.RegisterModuleInterface<IInventoryArchiverModule>(this); |
113 | OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted; | 113 | OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted; |
114 | OnInventoryArchiveLoaded += LoadInvConsoleCommandCompleted; | ||
114 | 115 | ||
115 | scene.AddCommand( | 116 | scene.AddCommand( |
116 | "Archiving", this, "load iar", | 117 | "Archiving", this, "load iar", |
@@ -139,7 +140,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
139 | + "-e|--exclude=<name/uuid> don't save the inventory item in archive" + Environment.NewLine | 140 | + "-e|--exclude=<name/uuid> don't save the inventory item in archive" + Environment.NewLine |
140 | + "-f|--excludefolder=<folder/uuid> don't save contents of the folder in archive" + Environment.NewLine | 141 | + "-f|--excludefolder=<folder/uuid> don't save contents of the folder in archive" + Environment.NewLine |
141 | + "-v|--verbose extra debug messages.\n" | 142 | + "-v|--verbose extra debug messages.\n" |
142 | + "--noassets stops assets being saved to the IAR.", | 143 | + "--noassets stops assets being saved to the IAR." |
144 | + "--perm=<permissions> stops items with insufficient permissions from being saved to the IAR.\n" | ||
145 | + " <permissions> can contain one or more of these characters: \"C\" = Copy, \"T\" = Transfer, \"M\" = Modify.\n", | ||
143 | HandleSaveInvConsoleCommand); | 146 | HandleSaveInvConsoleCommand); |
144 | 147 | ||
145 | m_aScene = scene; | 148 | m_aScene = scene; |
@@ -175,22 +178,34 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
175 | /// Trigger the inventory archive saved event. | 178 | /// Trigger the inventory archive saved event. |
176 | /// </summary> | 179 | /// </summary> |
177 | protected internal void TriggerInventoryArchiveSaved( | 180 | protected internal void TriggerInventoryArchiveSaved( |
178 | Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, | 181 | UUID id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, |
179 | Exception reportedException) | 182 | Exception reportedException, int SaveCount, int FilterCount) |
180 | { | 183 | { |
181 | InventoryArchiveSaved handlerInventoryArchiveSaved = OnInventoryArchiveSaved; | 184 | InventoryArchiveSaved handlerInventoryArchiveSaved = OnInventoryArchiveSaved; |
182 | if (handlerInventoryArchiveSaved != null) | 185 | if (handlerInventoryArchiveSaved != null) |
183 | handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException); | 186 | handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException, SaveCount , FilterCount); |
187 | } | ||
188 | |||
189 | /// <summary> | ||
190 | /// Trigger the inventory archive loaded event. | ||
191 | /// </summary> | ||
192 | protected internal void TriggerInventoryArchiveLoaded( | ||
193 | UUID id, bool succeeded, UserAccount userInfo, string invPath, Stream loadStream, | ||
194 | Exception reportedException, int LoadCount) | ||
195 | { | ||
196 | InventoryArchiveLoaded handlerInventoryArchiveLoaded = OnInventoryArchiveLoaded; | ||
197 | if (handlerInventoryArchiveLoaded != null) | ||
198 | handlerInventoryArchiveLoaded(id, succeeded, userInfo, invPath, loadStream, reportedException, LoadCount); | ||
184 | } | 199 | } |
185 | 200 | ||
186 | public bool ArchiveInventory( | 201 | public bool ArchiveInventory( |
187 | Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream) | 202 | UUID id, string firstName, string lastName, string invPath, string pass, Stream saveStream) |
188 | { | 203 | { |
189 | return ArchiveInventory(id, firstName, lastName, invPath, pass, saveStream, new Dictionary<string, object>()); | 204 | return ArchiveInventory(id, firstName, lastName, invPath, pass, saveStream, new Dictionary<string, object>()); |
190 | } | 205 | } |
191 | 206 | ||
192 | public bool ArchiveInventory( | 207 | public bool ArchiveInventory( |
193 | Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream, | 208 | UUID id, string firstName, string lastName, string invPath, string pass, Stream saveStream, |
194 | Dictionary<string, object> options) | 209 | Dictionary<string, object> options) |
195 | { | 210 | { |
196 | if (m_scenes.Count > 0) | 211 | if (m_scenes.Count > 0) |
@@ -230,7 +245,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
230 | } | 245 | } |
231 | 246 | ||
232 | public bool ArchiveInventory( | 247 | public bool ArchiveInventory( |
233 | Guid id, string firstName, string lastName, string invPath, string pass, string savePath, | 248 | UUID id, string firstName, string lastName, string invPath, string pass, string savePath, |
234 | Dictionary<string, object> options) | 249 | Dictionary<string, object> options) |
235 | { | 250 | { |
236 | // if (!ConsoleUtil.CheckFileDoesNotExist(MainConsole.Instance, savePath)) | 251 | // if (!ConsoleUtil.CheckFileDoesNotExist(MainConsole.Instance, savePath)) |
@@ -272,13 +287,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
272 | return false; | 287 | return false; |
273 | } | 288 | } |
274 | 289 | ||
275 | public bool DearchiveInventory(string firstName, string lastName, string invPath, string pass, Stream loadStream) | 290 | public bool DearchiveInventory(UUID id, string firstName, string lastName, string invPath, string pass, Stream loadStream) |
276 | { | 291 | { |
277 | return DearchiveInventory(firstName, lastName, invPath, pass, loadStream, new Dictionary<string, object>()); | 292 | return DearchiveInventory(id, firstName, lastName, invPath, pass, loadStream, new Dictionary<string, object>()); |
278 | } | 293 | } |
279 | 294 | ||
280 | public bool DearchiveInventory( | 295 | public bool DearchiveInventory( |
281 | string firstName, string lastName, string invPath, string pass, Stream loadStream, | 296 | UUID id, string firstName, string lastName, string invPath, string pass, Stream loadStream, |
282 | Dictionary<string, object> options) | 297 | Dictionary<string, object> options) |
283 | { | 298 | { |
284 | if (m_scenes.Count > 0) | 299 | if (m_scenes.Count > 0) |
@@ -294,7 +309,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
294 | 309 | ||
295 | try | 310 | try |
296 | { | 311 | { |
297 | request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream, merge); | 312 | request = new InventoryArchiveReadRequest(id, this, m_aScene.InventoryService, m_aScene.AssetService, m_aScene.UserAccountService, userInfo, invPath, loadStream, merge); |
298 | } | 313 | } |
299 | catch (EntryPointNotFoundException e) | 314 | catch (EntryPointNotFoundException e) |
300 | { | 315 | { |
@@ -326,7 +341,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
326 | } | 341 | } |
327 | 342 | ||
328 | public bool DearchiveInventory( | 343 | public bool DearchiveInventory( |
329 | string firstName, string lastName, string invPath, string pass, string loadPath, | 344 | UUID id, string firstName, string lastName, string invPath, string pass, string loadPath, |
330 | Dictionary<string, object> options) | 345 | Dictionary<string, object> options) |
331 | { | 346 | { |
332 | if (m_scenes.Count > 0) | 347 | if (m_scenes.Count > 0) |
@@ -342,7 +357,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
342 | 357 | ||
343 | try | 358 | try |
344 | { | 359 | { |
345 | request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath, merge); | 360 | request = new InventoryArchiveReadRequest(id, this, m_aScene.InventoryService, m_aScene.AssetService, m_aScene.UserAccountService, userInfo, invPath, loadPath, merge); |
346 | } | 361 | } |
347 | catch (EntryPointNotFoundException e) | 362 | catch (EntryPointNotFoundException e) |
348 | { | 363 | { |
@@ -378,6 +393,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
378 | { | 393 | { |
379 | try | 394 | try |
380 | { | 395 | { |
396 | UUID id = UUID.Random(); | ||
397 | |||
381 | Dictionary<string, object> options = new Dictionary<string, object>(); | 398 | Dictionary<string, object> options = new Dictionary<string, object>(); |
382 | OptionSet optionSet = new OptionSet().Add("m|merge", delegate (string v) { options["merge"] = v != null; }); | 399 | OptionSet optionSet = new OptionSet().Add("m|merge", delegate (string v) { options["merge"] = v != null; }); |
383 | 400 | ||
@@ -400,10 +417,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
400 | "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}", | 417 | "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}", |
401 | loadPath, invPath, firstName, lastName); | 418 | loadPath, invPath, firstName, lastName); |
402 | 419 | ||
403 | if (DearchiveInventory(firstName, lastName, invPath, pass, loadPath, options)) | 420 | lock (m_pendingConsoleTasks) |
404 | m_log.InfoFormat( | 421 | m_pendingConsoleTasks.Add(id); |
405 | "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}", | 422 | |
406 | loadPath, firstName, lastName); | 423 | DearchiveInventory(id, firstName, lastName, invPath, pass, loadPath, options); |
407 | } | 424 | } |
408 | catch (InventoryArchiverException e) | 425 | catch (InventoryArchiverException e) |
409 | { | 426 | { |
@@ -417,7 +434,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
417 | /// <param name="cmdparams"></param> | 434 | /// <param name="cmdparams"></param> |
418 | protected void HandleSaveInvConsoleCommand(string module, string[] cmdparams) | 435 | protected void HandleSaveInvConsoleCommand(string module, string[] cmdparams) |
419 | { | 436 | { |
420 | Guid id = Guid.NewGuid(); | 437 | UUID id = UUID.Random(); |
421 | 438 | ||
422 | Dictionary<string, object> options = new Dictionary<string, object>(); | 439 | Dictionary<string, object> options = new Dictionary<string, object>(); |
423 | 440 | ||
@@ -439,6 +456,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
439 | options["excludefolders"] = new List<String>(); | 456 | options["excludefolders"] = new List<String>(); |
440 | ((List<String>)options["excludefolders"]).Add(v); | 457 | ((List<String>)options["excludefolders"]).Add(v); |
441 | }); | 458 | }); |
459 | ops.Add("perm=", delegate(string v) { options["checkPermissions"] = v; }); | ||
442 | 460 | ||
443 | List<string> mainParams = ops.Parse(cmdparams); | 461 | List<string> mainParams = ops.Parse(cmdparams); |
444 | 462 | ||
@@ -464,8 +482,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
464 | "[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}", | 482 | "[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}", |
465 | savePath, invPath, firstName, lastName); | 483 | savePath, invPath, firstName, lastName); |
466 | 484 | ||
467 | lock (m_pendingConsoleSaves) | 485 | lock (m_pendingConsoleTasks) |
468 | m_pendingConsoleSaves.Add(id); | 486 | m_pendingConsoleTasks.Add(id); |
469 | 487 | ||
470 | ArchiveInventory(id, firstName, lastName, invPath, pass, savePath, options); | 488 | ArchiveInventory(id, firstName, lastName, invPath, pass, savePath, options); |
471 | } | 489 | } |
@@ -476,20 +494,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
476 | } | 494 | } |
477 | 495 | ||
478 | private void SaveInvConsoleCommandCompleted( | 496 | private void SaveInvConsoleCommandCompleted( |
479 | Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, | 497 | UUID id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, |
480 | Exception reportedException) | 498 | Exception reportedException, int SaveCount, int FilterCount) |
481 | { | 499 | { |
482 | lock (m_pendingConsoleSaves) | 500 | lock (m_pendingConsoleTasks) |
483 | { | 501 | { |
484 | if (m_pendingConsoleSaves.Contains(id)) | 502 | if (m_pendingConsoleTasks.Contains(id)) |
485 | m_pendingConsoleSaves.Remove(id); | 503 | m_pendingConsoleTasks.Remove(id); |
486 | else | 504 | else |
487 | return; | 505 | return; |
488 | } | 506 | } |
489 | 507 | ||
490 | if (succeeded) | 508 | if (succeeded) |
491 | { | 509 | { |
492 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Saved archive for {0} {1}", userInfo.FirstName, userInfo.LastName); | 510 | // Report success and include item count and filter count (Skipped items due to --perm or --exclude switches) |
511 | if(FilterCount == 0) | ||
512 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Saved archive with {0} items for {1} {2}", SaveCount, userInfo.FirstName, userInfo.LastName); | ||
513 | else | ||
514 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Saved archive with {0} items for {1} {2}. Skipped {3} items due to exclude and/or perm switches", SaveCount, userInfo.FirstName, userInfo.LastName, FilterCount); | ||
493 | } | 515 | } |
494 | else | 516 | else |
495 | { | 517 | { |
@@ -499,6 +521,30 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
499 | } | 521 | } |
500 | } | 522 | } |
501 | 523 | ||
524 | private void LoadInvConsoleCommandCompleted( | ||
525 | UUID id, bool succeeded, UserAccount userInfo, string invPath, Stream loadStream, | ||
526 | Exception reportedException, int LoadCount) | ||
527 | { | ||
528 | lock (m_pendingConsoleTasks) | ||
529 | { | ||
530 | if (m_pendingConsoleTasks.Contains(id)) | ||
531 | m_pendingConsoleTasks.Remove(id); | ||
532 | else | ||
533 | return; | ||
534 | } | ||
535 | |||
536 | if (succeeded) | ||
537 | { | ||
538 | m_log.InfoFormat("[INVENTORY ARCHIVER]: Loaded {0} items from archive {1} for {2} {3}", LoadCount, invPath, userInfo.FirstName, userInfo.LastName); | ||
539 | } | ||
540 | else | ||
541 | { | ||
542 | m_log.ErrorFormat( | ||
543 | "[INVENTORY ARCHIVER]: Archive load for {0} {1} failed - {2}", | ||
544 | userInfo.FirstName, userInfo.LastName, reportedException.Message); | ||
545 | } | ||
546 | } | ||
547 | |||
502 | /// <summary> | 548 | /// <summary> |
503 | /// Get user information for the given name. | 549 | /// Get user information for the given name. |
504 | /// </summary> | 550 | /// </summary> |
@@ -536,7 +582,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
536 | } | 582 | } |
537 | catch (Exception e) | 583 | catch (Exception e) |
538 | { | 584 | { |
539 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: Could not authenticate password, {0}", e.Message); | 585 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: Could not authenticate password, {0}", e); |
540 | return null; | 586 | return null; |
541 | } | 587 | } |
542 | } | 588 | } |