aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorDiva Canto2014-07-04 15:56:32 -0700
committerDiva Canto2014-07-04 15:56:32 -0700
commitdac870394984b197e76321afcdf7d554c747081d (patch)
tree9f07b7db098867c5303b841bca81727ea1f19686 /OpenSim/Region
parentInstrument the UDP path of creating assets so that it triggers an asset post ... (diff)
parentminor: put standard 'category' in brackets at front of log messages from prev... (diff)
downloadopensim-SC-dac870394984b197e76321afcdf7d554c747081d.zip
opensim-SC-dac870394984b197e76321afcdf7d554c747081d.tar.gz
opensim-SC-dac870394984b197e76321afcdf7d554c747081d.tar.bz2
opensim-SC-dac870394984b197e76321afcdf7d554c747081d.tar.xz
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs69
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs10
-rw-r--r--OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs47
-rw-r--r--OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs7
4 files changed, 129 insertions, 4 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
index 0eb15f8..238aff4 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
@@ -44,6 +44,7 @@ using OpenSim.Region.Framework.Scenes;
44using OpenSim.Region.Framework.Scenes.Serialization; 44using OpenSim.Region.Framework.Scenes.Serialization;
45using OpenSim.Framework.Servers; 45using OpenSim.Framework.Servers;
46using OpenSim.Framework.Servers.HttpServer; 46using OpenSim.Framework.Servers.HttpServer;
47using OpenSim.Framework.Client;
47using OpenSim.Services.Interfaces; 48using OpenSim.Services.Interfaces;
48 49
49using Caps = OpenSim.Framework.Capabilities.Caps; 50using Caps = OpenSim.Framework.Capabilities.Caps;
@@ -536,6 +537,42 @@ namespace OpenSim.Region.ClientStack.Linden
536 OSDArray texture_list = (OSDArray)request["texture_list"]; 537 OSDArray texture_list = (OSDArray)request["texture_list"];
537 SceneObjectGroup grp = null; 538 SceneObjectGroup grp = null;
538 539
540 InventoryFolderBase textureUploadFolder = null;
541
542 List<InventoryFolderBase> foldersToUpdate = new List<InventoryFolderBase>();
543 List<InventoryItemBase> itemsToUpdate = new List<InventoryItemBase>();
544 IClientInventory clientInv = null;
545
546 if (texture_list.Count > 0)
547 {
548 ScenePresence avatar = null;
549 IClientAPI client = null;
550 m_Scene.TryGetScenePresence(m_HostCapsObj.AgentID, out avatar);
551
552 if (avatar != null)
553 {
554 IClientCore core = (IClientCore)avatar.ControllingClient;
555
556 if (core.TryGet<IClientInventory>(out clientInv))
557 {
558 var systemTextureFolder = m_Scene.InventoryService.GetFolderForType(m_HostCapsObj.AgentID, AssetType.Texture);
559 textureUploadFolder = new InventoryFolderBase(UUID.Random(), assetName, m_HostCapsObj.AgentID, (short)AssetType.Unknown, systemTextureFolder.ID, 1);
560 if (m_Scene.InventoryService.AddFolder(textureUploadFolder))
561 {
562 foldersToUpdate.Add(textureUploadFolder);
563
564 m_log.DebugFormat(
565 "[BUNCH OF CAPS]: Created new folder '{0}' ({1}) for textures uploaded with mesh object {2}",
566 textureUploadFolder.Name, textureUploadFolder.ID, assetName);
567 }
568 else
569 {
570 textureUploadFolder = null;
571 }
572 }
573 }
574 }
575
539 List<UUID> textures = new List<UUID>(); 576 List<UUID> textures = new List<UUID>();
540 for (int i = 0; i < texture_list.Count; i++) 577 for (int i = 0; i < texture_list.Count; i++)
541 { 578 {
@@ -543,6 +580,38 @@ namespace OpenSim.Region.ClientStack.Linden
543 textureAsset.Data = texture_list[i].AsBinary(); 580 textureAsset.Data = texture_list[i].AsBinary();
544 m_assetService.Store(textureAsset); 581 m_assetService.Store(textureAsset);
545 textures.Add(textureAsset.FullID); 582 textures.Add(textureAsset.FullID);
583
584 if (textureUploadFolder != null)
585 {
586 InventoryItemBase textureItem = new InventoryItemBase();
587 textureItem.Owner = m_HostCapsObj.AgentID;
588 textureItem.CreatorId = m_HostCapsObj.AgentID.ToString();
589 textureItem.CreatorData = String.Empty;
590 textureItem.ID = UUID.Random();
591 textureItem.AssetID = textureAsset.FullID;
592 textureItem.Description = assetDescription;
593 textureItem.Name = assetName + " - Texture " + (i + 1).ToString();
594 textureItem.AssetType = (int)AssetType.Texture;
595 textureItem.InvType = (int)InventoryType.Texture;
596 textureItem.Folder = textureUploadFolder.ID;
597 textureItem.CurrentPermissions
598 = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer | PermissionMask.Export);
599 textureItem.BasePermissions = (uint)PermissionMask.All | (uint)PermissionMask.Export;
600 textureItem.EveryOnePermissions = 0;
601 textureItem.NextPermissions = (uint)PermissionMask.All;
602 textureItem.CreationDate = Util.UnixTimeSinceEpoch();
603 m_Scene.InventoryService.AddItem(textureItem);
604 itemsToUpdate.Add(textureItem);
605
606 m_log.DebugFormat(
607 "[BUNCH OF CAPS]: Created new inventory item '{0}' ({1}) for texture uploaded with mesh object {2}",
608 textureItem.Name, textureItem.ID, assetName);
609 }
610 }
611
612 if (clientInv != null && (foldersToUpdate.Count > 0 || itemsToUpdate.Count > 0))
613 {
614 clientInv.SendBulkUpdateInventory(foldersToUpdate.ToArray(), itemsToUpdate.ToArray());
546 } 615 }
547 616
548 for (int i = 0; i < mesh_list.Count; i++) 617 for (int i = 0; i < mesh_list.Count; i++)
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 9abc8ae..f531859 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -1874,8 +1874,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1874 // m_log.DebugFormat("[XXX] --> {0}", h); 1874 // m_log.DebugFormat("[XXX] --> {0}", h);
1875 //m_log.DebugFormat("[XXX] Adding {0}", region.RegionHandle); 1875 //m_log.DebugFormat("[XXX] Adding {0}", region.RegionHandle);
1876 if (agent.ChildrenCapSeeds.ContainsKey(region.RegionHandle)) 1876 if (agent.ChildrenCapSeeds.ContainsKey(region.RegionHandle))
1877 agent.ChildrenCapSeeds.Remove(region.RegionHandle); 1877 {
1878 agent.ChildrenCapSeeds.Add(region.RegionHandle, agent.CapsPath); 1878 m_log.WarnFormat(
1879 "[ENTITY TRANSFER]: Overwriting caps seed {0} with {1} for region {2} (handle {3}) for {4} in {5}",
1880 agent.ChildrenCapSeeds[region.RegionHandle], agent.CapsPath,
1881 region.RegionName, region.RegionHandle, sp.Name, Scene.Name);
1882 }
1883
1884 agent.ChildrenCapSeeds[region.RegionHandle] = agent.CapsPath;
1879 1885
1880 if (sp.Scene.CapsModule != null) 1886 if (sp.Scene.CapsModule != null)
1881 { 1887 {
diff --git a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs
index bbb77ad..28dc5f5 100644
--- a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs
+++ b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs
@@ -78,6 +78,8 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
78 /// These conditions are heuristics to try and avoid taking a backup when the sim is busy. 78 /// These conditions are heuristics to try and avoid taking a backup when the sim is busy.
79 /// AutoBackupSkipAssets 79 /// AutoBackupSkipAssets
80 /// If true, assets are not saved to the oar file. Considerably reduces impact on simulator when backing up. Intended for when assets db is backed up separately 80 /// If true, assets are not saved to the oar file. Considerably reduces impact on simulator when backing up. Intended for when assets db is backed up separately
81 /// AutoBackupKeepFilesForDays
82 /// Backup files older than this value (in days) are deleted during the current backup process, 0 will disable this and keep all backup files indefinitely
81 /// AutoBackupScript: String. Default: not specified (disabled). 83 /// AutoBackupScript: String. Default: not specified (disabled).
82 /// File path to an executable script or binary to run when an automatic backup is taken. 84 /// File path to an executable script or binary to run when an automatic backup is taken.
83 /// The file should really be (Windows) an .exe or .bat, or (Linux/Mac) a shell script or binary. 85 /// The file should really be (Windows) an .exe or .bat, or (Linux/Mac) a shell script or binary.
@@ -429,6 +431,19 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
429 state.SkipAssets = tmpSkipAssets; 431 state.SkipAssets = tmpSkipAssets;
430 } 432 }
431 433
434 // How long to keep backup files in days, 0 Disables this feature
435 int tmpKeepFilesForDays = ResolveInt("AutoBackupKeepFilesForDays",
436 this.m_defaultState.KeepFilesForDays, config, regionConfig);
437 if (state == null && tmpKeepFilesForDays != this.m_defaultState.KeepFilesForDays)
438 {
439 state = new AutoBackupModuleState();
440 }
441
442 if (state != null)
443 {
444 state.KeepFilesForDays = tmpKeepFilesForDays;
445 }
446
432 // Set file naming algorithm 447 // Set file naming algorithm
433 string stmpNamingType = ResolveString("AutoBackupNaming", 448 string stmpNamingType = ResolveString("AutoBackupNaming",
434 this.m_defaultState.NamingType.ToString(), config, regionConfig); 449 this.m_defaultState.NamingType.ToString(), config, regionConfig);
@@ -497,7 +512,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
497 catch (Exception e) 512 catch (Exception e)
498 { 513 {
499 m_log.Warn( 514 m_log.Warn(
500 "BAD NEWS. You won't be able to save backups to directory " + 515 "[AUTO BACKUP]: BAD NEWS. You won't be able to save backups to directory " +
501 state.BackupDir + 516 state.BackupDir +
502 " because it doesn't exist or there's a permissions issue with it. Here's the exception.", 517 " because it doesn't exist or there's a permissions issue with it. Here's the exception.",
503 e); 518 e);
@@ -614,7 +629,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
614 bool heuristicsPassed = false; 629 bool heuristicsPassed = false;
615 if (!this.m_timerMap.ContainsKey((Timer) sender)) 630 if (!this.m_timerMap.ContainsKey((Timer) sender))
616 { 631 {
617 m_log.Debug("Code-up error: timerMap doesn't contain timer " + sender); 632 m_log.Debug("[AUTO BACKUP]: Code-up error: timerMap doesn't contain timer " + sender);
618 } 633 }
619 634
620 List<IScene> tmap = this.m_timerMap[(Timer) sender]; 635 List<IScene> tmap = this.m_timerMap[(Timer) sender];
@@ -650,6 +665,9 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
650 } 665 }
651 this.DoRegionBackup(scene); 666 this.DoRegionBackup(scene);
652 } 667 }
668
669 // Remove Old Backups
670 this.RemoveOldFiles(state);
653 } 671 }
654 } 672 }
655 } 673 }
@@ -694,6 +712,31 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
694 iram.ArchiveRegion(savePath, guid, options); 712 iram.ArchiveRegion(savePath, guid, options);
695 } 713 }
696 714
715 // For the given state, remove backup files older than the states KeepFilesForDays property
716 private void RemoveOldFiles(AutoBackupModuleState state)
717 {
718 // 0 Means Disabled, Keep Files Indefinitely
719 if (state.KeepFilesForDays > 0)
720 {
721 string[] files = Directory.GetFiles(state.BackupDir, "*.oar");
722 DateTime CuttOffDate = DateTime.Now.AddDays(0 - state.KeepFilesForDays);
723
724 foreach (string file in files)
725 {
726 try
727 {
728 FileInfo fi = new FileInfo(file);
729 if (fi.CreationTime < CuttOffDate)
730 fi.Delete();
731 }
732 catch (Exception Ex)
733 {
734 m_log.Error("[AUTO BACKUP]: Error deleting old backup file '" + file + "': " + Ex.Message);
735 }
736 }
737 }
738 }
739
697 /// <summary> 740 /// <summary>
698 /// Called by the Event Manager when the OnOarFileSaved event is fired. 741 /// Called by the Event Manager when the OnOarFileSaved event is fired.
699 /// </summary> 742 /// </summary>
diff --git a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs
index ade25a5..ce7c368 100644
--- a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs
+++ b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs
@@ -49,6 +49,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
49 this.Timer = null; 49 this.Timer = null;
50 this.NamingType = NamingType.Time; 50 this.NamingType = NamingType.Time;
51 this.Script = null; 51 this.Script = null;
52 this.KeepFilesForDays = 0;
52 } 53 }
53 54
54 public Dictionary<Guid, string> LiveRequests 55 public Dictionary<Guid, string> LiveRequests
@@ -116,6 +117,12 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
116 set; 117 set;
117 } 118 }
118 119
120 public int KeepFilesForDays
121 {
122 get;
123 set;
124 }
125
119 public new string ToString() 126 public new string ToString()
120 { 127 {
121 string retval = ""; 128 string retval = "";