* Actually persist restored archives to the database - wasn't actually doing this before (doh)
* Not quite perfect yet0.6.0-stable
parent
bd9736c9f8
commit
eb63b9bbc1
|
@ -71,6 +71,9 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
|
|
||||||
List<string> serialisedSceneObjects = new List<string>();
|
List<string> serialisedSceneObjects = new List<string>();
|
||||||
string filePath = "ERROR";
|
string filePath = "ERROR";
|
||||||
|
|
||||||
|
int successfulAssetRestores = 0;
|
||||||
|
int failedAssetRestores = 0;
|
||||||
|
|
||||||
byte[] data;
|
byte[] data;
|
||||||
while ((data = archive.ReadEntry(out filePath)) != null)
|
while ((data = archive.ReadEntry(out filePath)) != null)
|
||||||
|
@ -89,7 +92,10 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
// }
|
// }
|
||||||
else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
|
else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
|
||||||
{
|
{
|
||||||
LoadAsset(filePath, data);
|
if (LoadAsset(filePath, data))
|
||||||
|
successfulAssetRestores++;
|
||||||
|
else
|
||||||
|
failedAssetRestores++;
|
||||||
}
|
}
|
||||||
else if (filePath.StartsWith(ArchiveConstants.TERRAINS_PATH))
|
else if (filePath.StartsWith(ArchiveConstants.TERRAINS_PATH))
|
||||||
{
|
{
|
||||||
|
@ -100,9 +106,14 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
//m_log.Debug("[ARCHIVER]: Reached end of archive");
|
//m_log.Debug("[ARCHIVER]: Reached end of archive");
|
||||||
|
|
||||||
archive.Close();
|
archive.Close();
|
||||||
|
|
||||||
|
m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores);
|
||||||
|
|
||||||
|
if (failedAssetRestores > 0)
|
||||||
|
m_log.ErrorFormat("[ARCHIVER]: Failed to load {0} assets", failedAssetRestores);
|
||||||
|
|
||||||
// Reload serialized prims
|
// Reload serialized prims
|
||||||
m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects", serialisedSceneObjects.Count);
|
m_log.InfoFormat("[ARCHIVER]: Loading {0} scene objects. Please wait.", serialisedSceneObjects.Count);
|
||||||
|
|
||||||
IRegionSerialiser serialiser = m_scene.RequestModuleInterface<IRegionSerialiser>();
|
IRegionSerialiser serialiser = m_scene.RequestModuleInterface<IRegionSerialiser>();
|
||||||
ICollection<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
|
ICollection<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
|
||||||
|
@ -115,12 +126,12 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
sceneObjects.Add(sceneObject);
|
sceneObjects.Add(sceneObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_log.InfoFormat("[ARCHIVER]: Restored {0} objects to the scene", sceneObjects.Count);
|
m_log.InfoFormat("[ARCHIVER]: Restored {0} scene objects to the scene", sceneObjects.Count);
|
||||||
|
|
||||||
int ignoredObjects = serialisedSceneObjects.Count - sceneObjects.Count;
|
int ignoredObjects = serialisedSceneObjects.Count - sceneObjects.Count;
|
||||||
|
|
||||||
if (ignoredObjects > 0)
|
if (ignoredObjects > 0)
|
||||||
m_log.WarnFormat("[ARCHIVER]: Ignored {0} objects that already existed in the scene", ignoredObjects);
|
m_log.WarnFormat("[ARCHIVER]: Ignored {0} scene objects that already existed in the scene", ignoredObjects);
|
||||||
|
|
||||||
m_log.InfoFormat("[ARCHIVER]: Successfully loaded archive");
|
m_log.InfoFormat("[ARCHIVER]: Successfully loaded archive");
|
||||||
|
|
||||||
|
@ -149,7 +160,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
{
|
{
|
||||||
sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];
|
sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];
|
||||||
|
|
||||||
m_log.DebugFormat("[ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType);
|
//m_log.DebugFormat("[ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType);
|
||||||
|
|
||||||
AssetBase asset = new AssetBase(new LLUUID(uuid), String.Empty);
|
AssetBase asset = new AssetBase(new LLUUID(uuid), String.Empty);
|
||||||
asset.Type = assetType;
|
asset.Type = assetType;
|
||||||
|
@ -185,7 +196,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
terrainModule.LoadFromStream(terrainPath, ms);
|
terrainModule.LoadFromStream(terrainPath, ms);
|
||||||
ms.Close();
|
ms.Close();
|
||||||
|
|
||||||
m_log.DebugFormat("[ARCHIVER]: Successfully loaded terrain {0}", terrainPath);
|
m_log.DebugFormat("[ARCHIVER]: Restored terrain {0}", terrainPath);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,7 +215,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
|
|
||||||
// XXX: Not a great way to iterate through face textures, but there's no
|
// XXX: Not a great way to iterate through face textures, but there's no
|
||||||
// other method available to tell how many faces there actually are
|
// other method available to tell how many faces there actually are
|
||||||
int i = 0;
|
//int i = 0;
|
||||||
foreach (LLObject.TextureEntryFace texture in textureEntry.FaceTextures)
|
foreach (LLObject.TextureEntryFace texture in textureEntry.FaceTextures)
|
||||||
{
|
{
|
||||||
if (texture != null)
|
if (texture != null)
|
||||||
|
|
|
@ -185,7 +185,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
SceneObjectGroup obj = new SceneObjectGroup(xmlData);
|
SceneObjectGroup obj = new SceneObjectGroup(xmlData);
|
||||||
|
|
||||||
if (scene.AddRestoredSceneObject(obj, true))
|
if (scene.AddRestoredSceneObject(obj, true, false))
|
||||||
return obj;
|
return obj;
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -196,10 +196,15 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
/// If true, changes to the object will be reflected in its persisted data
|
/// If true, changes to the object will be reflected in its persisted data
|
||||||
/// If false, the persisted data will not be changed even if the object in the scene is changed
|
/// If false, the persisted data will not be changed even if the object in the scene is changed
|
||||||
/// </param>
|
/// </param>
|
||||||
|
/// <param name="alreadyPersisted">
|
||||||
|
/// If true, we won't persist this object until it changes
|
||||||
|
/// If false, we'll persist this object immediately
|
||||||
|
/// </param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// true if the object was added, false if an object with the same uuid was already in the scene
|
/// true if the object was added, false if an object with the same uuid was already in the scene
|
||||||
/// </returns>
|
/// </returns>
|
||||||
protected internal bool AddRestoredSceneObject(SceneObjectGroup sceneObject, bool attachToBackup)
|
protected internal bool AddRestoredSceneObject(
|
||||||
|
SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted)
|
||||||
{
|
{
|
||||||
sceneObject.RegionHandle = m_regInfo.RegionHandle;
|
sceneObject.RegionHandle = m_regInfo.RegionHandle;
|
||||||
sceneObject.SetScene(m_parentScene);
|
sceneObject.SetScene(m_parentScene);
|
||||||
|
@ -211,6 +216,12 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
sceneObject.UpdateParentIDs();
|
sceneObject.UpdateParentIDs();
|
||||||
|
|
||||||
|
if (!alreadyPersisted)
|
||||||
|
{
|
||||||
|
sceneObject.ForceInventoryPersistence();
|
||||||
|
sceneObject.HasGroupChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
return AddSceneObject(sceneObject, attachToBackup);
|
return AddSceneObject(sceneObject, attachToBackup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1485,7 +1485,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
List<SceneObjectGroup> PrimsFromDB = m_storageManager.DataStore.LoadObjects(regionID);
|
List<SceneObjectGroup> PrimsFromDB = m_storageManager.DataStore.LoadObjects(regionID);
|
||||||
foreach (SceneObjectGroup group in PrimsFromDB)
|
foreach (SceneObjectGroup group in PrimsFromDB)
|
||||||
{
|
{
|
||||||
AddRestoredSceneObject(group, true);
|
AddRestoredSceneObject(group, true, true);
|
||||||
SceneObjectPart rootPart = group.GetChildPart(group.UUID);
|
SceneObjectPart rootPart = group.GetChildPart(group.UUID);
|
||||||
rootPart.ObjectFlags &= ~(uint)LLObject.ObjectFlags.Scripted;
|
rootPart.ObjectFlags &= ~(uint)LLObject.ObjectFlags.Scripted;
|
||||||
rootPart.TrimPermissions();
|
rootPart.TrimPermissions();
|
||||||
|
@ -1665,9 +1665,21 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
/// Add an object into the scene that has come from storage
|
/// Add an object into the scene that has come from storage
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sceneObject"></param>
|
/// <param name="sceneObject"></param>
|
||||||
public bool AddRestoredSceneObject(SceneObjectGroup sceneObject, bool attachToBackup)
|
/// <param name="attachToBackup">
|
||||||
|
/// If true, changes to the object will be reflected in its persisted data
|
||||||
|
/// If false, the persisted data will not be changed even if the object in the scene is changed
|
||||||
|
/// </param>
|
||||||
|
/// <param name="alreadyPersisted">
|
||||||
|
/// If true, we won't persist this object until it changes
|
||||||
|
/// If false, we'll persist this object immediately
|
||||||
|
/// </param>
|
||||||
|
/// <returns>
|
||||||
|
/// true if the object was added, false if an object with the same uuid was already in the scene
|
||||||
|
/// </returns>
|
||||||
|
public bool AddRestoredSceneObject(
|
||||||
|
SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted)
|
||||||
{
|
{
|
||||||
return m_innerScene.AddRestoredSceneObject(sceneObject, attachToBackup);
|
return m_innerScene.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -38,6 +38,20 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Force all task inventories of prims in the scene object to persist
|
||||||
|
/// </summary>
|
||||||
|
public void ForceInventoryPersistence()
|
||||||
|
{
|
||||||
|
lock (m_parts)
|
||||||
|
{
|
||||||
|
foreach (SceneObjectPart part in m_parts.Values)
|
||||||
|
{
|
||||||
|
part.ForceInventoryPersistence();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Start the scripts contained in all the prims in this group.
|
/// Start the scripts contained in all the prims in this group.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -53,6 +67,9 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stop the scripts contained in all the prims in this group
|
||||||
|
/// </summary>
|
||||||
public void RemoveScriptInstances()
|
public void RemoveScriptInstances()
|
||||||
{
|
{
|
||||||
lock (m_parts)
|
lock (m_parts)
|
||||||
|
|
|
@ -1396,7 +1396,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// Make a copy of the given part.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="part"></param>
|
/// <param name="part"></param>
|
||||||
/// <param name="cAgentID"></param>
|
/// <param name="cAgentID"></param>
|
||||||
|
|
|
@ -58,7 +58,15 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tracks whether inventory has changed since the last persistent backup
|
/// Tracks whether inventory has changed since the last persistent backup
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private bool HasInventoryChanged;
|
protected bool HasInventoryChanged;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Force the task inventory of this prim to persist at the next update sweep
|
||||||
|
/// </summary>
|
||||||
|
public void ForceInventoryPersistence()
|
||||||
|
{
|
||||||
|
HasInventoryChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reset LLUUIDs for all the items in the prim's inventory. This involves either generating
|
/// Reset LLUUIDs for all the items in the prim's inventory. This involves either generating
|
||||||
|
@ -72,9 +80,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
lock (TaskInventory)
|
lock (TaskInventory)
|
||||||
{
|
{
|
||||||
if (0 == TaskInventory.Count)
|
if (0 == TaskInventory.Count)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
HasInventoryChanged = true;
|
HasInventoryChanged = true;
|
||||||
ParentGroup.HasGroupChanged = true;
|
ParentGroup.HasGroupChanged = true;
|
||||||
|
@ -597,7 +603,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
public void ProcessInventoryBackup(IRegionDataStore datastore)
|
public void ProcessInventoryBackup(IRegionDataStore datastore)
|
||||||
{
|
{
|
||||||
if (HasInventoryChanged)
|
if (HasInventoryChanged)
|
||||||
{
|
{
|
||||||
lock (TaskInventory)
|
lock (TaskInventory)
|
||||||
{
|
{
|
||||||
datastore.StorePrimInventory(UUID, TaskInventory.Values);
|
datastore.StorePrimInventory(UUID, TaskInventory.Values);
|
||||||
|
|
Loading…
Reference in New Issue