aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
diff options
context:
space:
mode:
authorAliciaRaven2014-09-06 20:23:40 +0100
committerJustin Clark-Casey (justincc)2014-09-23 00:04:53 +0100
commit5bc3bbbcf3e7df23db3e3e0410266ba72a1a1e14 (patch)
tree810e7e39cb5dfa5ee77f40f3c1ae3eae2a9175fd /OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
parentChange existing IAR save to use UUID for its callback reference instead of Gu... (diff)
downloadopensim-SC_OLD-5bc3bbbcf3e7df23db3e3e0410266ba72a1a1e14.zip
opensim-SC_OLD-5bc3bbbcf3e7df23db3e3e0410266ba72a1a1e14.tar.gz
opensim-SC_OLD-5bc3bbbcf3e7df23db3e3e0410266ba72a1a1e14.tar.bz2
opensim-SC_OLD-5bc3bbbcf3e7df23db3e3e0410266ba72a1a1e14.tar.xz
Add an event callback for loading IAR files. The callback for creating them already existed but not for loading. This is of interest for use by region modules. Also includes reporting numbers of items saved and items filtered to the completed log printout.
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs86
1 files changed, 65 insertions, 21 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index 0e4d79c..b85bbea 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -57,6 +57,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
57// public bool DisablePresenceChecks { get; set; } 57// public bool DisablePresenceChecks { get; set; }
58 58
59 public event InventoryArchiveSaved OnInventoryArchiveSaved; 59 public event InventoryArchiveSaved OnInventoryArchiveSaved;
60 public event InventoryArchiveLoaded OnInventoryArchiveLoaded;
60 61
61 /// <summary> 62 /// <summary>
62 /// 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
@@ -64,9 +65,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
64 protected const string DEFAULT_INV_BACKUP_FILENAME = "user-inventory.iar"; 65 protected const string DEFAULT_INV_BACKUP_FILENAME = "user-inventory.iar";
65 66
66 /// <value> 67 /// <value>
67 /// Pending save completions initiated from the console 68 /// Pending save and load completions initiated from the console
68 /// </value> 69 /// </value>
69 protected List<UUID> m_pendingConsoleSaves = new List<UUID>(); 70 protected List<UUID> m_pendingConsoleTasks = new List<UUID>();
70 71
71 /// <value> 72 /// <value>
72 /// All scenes that this module knows about 73 /// All scenes that this module knows about
@@ -111,6 +112,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
111 { 112 {
112 scene.RegisterModuleInterface<IInventoryArchiverModule>(this); 113 scene.RegisterModuleInterface<IInventoryArchiverModule>(this);
113 OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted; 114 OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted;
115 OnInventoryArchiveLoaded += LoadInvConsoleCommandCompleted;
114 116
115 scene.AddCommand( 117 scene.AddCommand(
116 "Archiving", this, "load iar", 118 "Archiving", this, "load iar",
@@ -176,11 +178,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
176 /// </summary> 178 /// </summary>
177 protected internal void TriggerInventoryArchiveSaved( 179 protected internal void TriggerInventoryArchiveSaved(
178 UUID id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, 180 UUID id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream,
179 Exception reportedException) 181 Exception reportedException, int SaveCount, int FilterCount)
180 { 182 {
181 InventoryArchiveSaved handlerInventoryArchiveSaved = OnInventoryArchiveSaved; 183 InventoryArchiveSaved handlerInventoryArchiveSaved = OnInventoryArchiveSaved;
182 if (handlerInventoryArchiveSaved != null) 184 if (handlerInventoryArchiveSaved != null)
183 handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException); 185 handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException, SaveCount , FilterCount);
186 }
187
188 /// <summary>
189 /// Trigger the inventory archive loaded event.
190 /// </summary>
191 protected internal void TriggerInventoryArchiveLoaded(
192 UUID id, bool succeeded, UserAccount userInfo, string invPath, Stream loadStream,
193 Exception reportedException, int LoadCount)
194 {
195 InventoryArchiveLoaded handlerInventoryArchiveLoaded = OnInventoryArchiveLoaded;
196 if (handlerInventoryArchiveLoaded != null)
197 handlerInventoryArchiveLoaded(id, succeeded, userInfo, invPath, loadStream, reportedException, LoadCount);
184 } 198 }
185 199
186 public bool ArchiveInventory( 200 public bool ArchiveInventory(
@@ -272,13 +286,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
272 return false; 286 return false;
273 } 287 }
274 288
275 public bool DearchiveInventory(string firstName, string lastName, string invPath, string pass, Stream loadStream) 289 public bool DearchiveInventory(UUID id, string firstName, string lastName, string invPath, string pass, Stream loadStream)
276 { 290 {
277 return DearchiveInventory(firstName, lastName, invPath, pass, loadStream, new Dictionary<string, object>()); 291 return DearchiveInventory(id, firstName, lastName, invPath, pass, loadStream, new Dictionary<string, object>());
278 } 292 }
279 293
280 public bool DearchiveInventory( 294 public bool DearchiveInventory(
281 string firstName, string lastName, string invPath, string pass, Stream loadStream, 295 UUID id, string firstName, string lastName, string invPath, string pass, Stream loadStream,
282 Dictionary<string, object> options) 296 Dictionary<string, object> options)
283 { 297 {
284 if (m_scenes.Count > 0) 298 if (m_scenes.Count > 0)
@@ -294,7 +308,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
294 308
295 try 309 try
296 { 310 {
297 request = new InventoryArchiveReadRequest(m_aScene.InventoryService, m_aScene.AssetService, m_aScene.UserAccountService, userInfo, invPath, loadStream, merge); 311 request = new InventoryArchiveReadRequest(id, m_aScene.InventoryService, this, m_aScene.AssetService, m_aScene.UserAccountService, userInfo, invPath, loadStream, merge);
298 } 312 }
299 catch (EntryPointNotFoundException e) 313 catch (EntryPointNotFoundException e)
300 { 314 {
@@ -326,7 +340,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
326 } 340 }
327 341
328 public bool DearchiveInventory( 342 public bool DearchiveInventory(
329 string firstName, string lastName, string invPath, string pass, string loadPath, 343 UUID id, string firstName, string lastName, string invPath, string pass, string loadPath,
330 Dictionary<string, object> options) 344 Dictionary<string, object> options)
331 { 345 {
332 if (m_scenes.Count > 0) 346 if (m_scenes.Count > 0)
@@ -342,7 +356,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
342 356
343 try 357 try
344 { 358 {
345 request = new InventoryArchiveReadRequest(m_aScene.InventoryService, m_aScene.AssetService, m_aScene.UserAccountService, userInfo, invPath, loadPath, merge); 359 request = new InventoryArchiveReadRequest(id, m_aScene.InventoryService, this, m_aScene.AssetService, m_aScene.UserAccountService, userInfo, invPath, loadPath, merge);
346 } 360 }
347 catch (EntryPointNotFoundException e) 361 catch (EntryPointNotFoundException e)
348 { 362 {
@@ -378,6 +392,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
378 { 392 {
379 try 393 try
380 { 394 {
395 UUID id = UUID.Random();
396
381 Dictionary<string, object> options = new Dictionary<string, object>(); 397 Dictionary<string, object> options = new Dictionary<string, object>();
382 OptionSet optionSet = new OptionSet().Add("m|merge", delegate (string v) { options["merge"] = v != null; }); 398 OptionSet optionSet = new OptionSet().Add("m|merge", delegate (string v) { options["merge"] = v != null; });
383 399
@@ -400,10 +416,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
400 "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}", 416 "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}",
401 loadPath, invPath, firstName, lastName); 417 loadPath, invPath, firstName, lastName);
402 418
403 if (DearchiveInventory(firstName, lastName, invPath, pass, loadPath, options)) 419 lock (m_pendingConsoleTasks)
404 m_log.InfoFormat( 420 m_pendingConsoleTasks.Add(id);
405 "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}", 421
406 loadPath, firstName, lastName); 422 DearchiveInventory(id, firstName, lastName, invPath, pass, loadPath, options);
407 } 423 }
408 catch (InventoryArchiverException e) 424 catch (InventoryArchiverException e)
409 { 425 {
@@ -465,8 +481,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
465 "[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}", 481 "[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}",
466 savePath, invPath, firstName, lastName); 482 savePath, invPath, firstName, lastName);
467 483
468 lock (m_pendingConsoleSaves) 484 lock (m_pendingConsoleTasks)
469 m_pendingConsoleSaves.Add(id); 485 m_pendingConsoleTasks.Add(id);
470 486
471 ArchiveInventory(id, firstName, lastName, invPath, pass, savePath, options); 487 ArchiveInventory(id, firstName, lastName, invPath, pass, savePath, options);
472 } 488 }
@@ -478,19 +494,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
478 494
479 private void SaveInvConsoleCommandCompleted( 495 private void SaveInvConsoleCommandCompleted(
480 UUID id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, 496 UUID id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream,
481 Exception reportedException) 497 Exception reportedException, int SaveCount, int FilterCount)
482 { 498 {
483 lock (m_pendingConsoleSaves) 499 lock (m_pendingConsoleTasks)
484 { 500 {
485 if (m_pendingConsoleSaves.Contains(id)) 501 if (m_pendingConsoleTasks.Contains(id))
486 m_pendingConsoleSaves.Remove(id); 502 m_pendingConsoleTasks.Remove(id);
487 else 503 else
488 return; 504 return;
489 } 505 }
490 506
491 if (succeeded) 507 if (succeeded)
492 { 508 {
493 m_log.InfoFormat("[INVENTORY ARCHIVER]: Saved archive for {0} {1}", userInfo.FirstName, userInfo.LastName); 509 // Report success and include item count and filter count (Skipped items due to --perm or --exclude switches)
510 if(FilterCount == 0)
511 m_log.InfoFormat("[INVENTORY ARCHIVER]: Saved archive with {0} items for {1} {2}", SaveCount, userInfo.FirstName, userInfo.LastName);
512 else
513 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);
494 } 514 }
495 else 515 else
496 { 516 {
@@ -500,6 +520,30 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
500 } 520 }
501 } 521 }
502 522
523 private void LoadInvConsoleCommandCompleted(
524 UUID id, bool succeeded, UserAccount userInfo, string invPath, Stream loadStream,
525 Exception reportedException, int LoadCount)
526 {
527 lock (m_pendingConsoleTasks)
528 {
529 if (m_pendingConsoleTasks.Contains(id))
530 m_pendingConsoleTasks.Remove(id);
531 else
532 return;
533 }
534
535 if (succeeded)
536 {
537 m_log.InfoFormat("[INVENTORY ARCHIVER]: Loaded {0} items from archive {1} for {2} {3}", LoadCount, invPath, userInfo.FirstName, userInfo.LastName);
538 }
539 else
540 {
541 m_log.ErrorFormat(
542 "[INVENTORY ARCHIVER]: Archive load for {0} {1} failed - {2}",
543 userInfo.FirstName, userInfo.LastName, reportedException.Message);
544 }
545 }
546
503 /// <summary> 547 /// <summary>
504 /// Get user information for the given name. 548 /// Get user information for the given name.
505 /// </summary> 549 /// </summary>