* Successfully pick out prims.xml file from archive
parent
48d0084e53
commit
ea4982e453
|
@ -861,4 +861,4 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
|
||||||
m_tcp.Close();
|
m_tcp.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the OpenSim Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Constants for the archiving module
|
||||||
|
/// </summary>
|
||||||
|
public class ArchiveConstants
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Path for the assets held in an archive
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string ASSETS_PATH = "assets/";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Path for the prims file
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string PRIMS_PATH = "prims.xml";
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,6 +26,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using OpenSim.Region.Environment.Scenes;
|
using OpenSim.Region.Environment.Scenes;
|
||||||
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
|
||||||
|
@ -38,6 +39,8 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
protected static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding();
|
||||||
|
|
||||||
private Scene m_scene;
|
private Scene m_scene;
|
||||||
private string m_loadPath;
|
private string m_loadPath;
|
||||||
|
|
||||||
|
@ -53,6 +56,8 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
{
|
{
|
||||||
TarArchiveReader archive = new TarArchiveReader(m_loadPath);
|
TarArchiveReader archive = new TarArchiveReader(m_loadPath);
|
||||||
|
|
||||||
|
string serializedPrims = string.Empty;
|
||||||
|
|
||||||
// Just test for now by reading first file
|
// Just test for now by reading first file
|
||||||
string filePath = "ERROR";
|
string filePath = "ERROR";
|
||||||
|
|
||||||
|
@ -60,11 +65,27 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
while ((data = archive.ReadEntry(out filePath)) != null)
|
while ((data = archive.ReadEntry(out filePath)) != null)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("[ARCHIVER]: Successfully read {0} ({1} bytes) from archive {2}", filePath, data.Length, m_loadPath);
|
m_log.DebugFormat("[ARCHIVER]: Successfully read {0} ({1} bytes) from archive {2}", filePath, data.Length, m_loadPath);
|
||||||
|
|
||||||
|
if (filePath.Equals(ArchiveConstants.PRIMS_PATH))
|
||||||
|
{
|
||||||
|
serializedPrims = m_asciiEncoding.GetString(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_log.DebugFormat("[ARCHIVER]: Reached end of archive");
|
m_log.DebugFormat("[ARCHIVER]: Reached end of archive");
|
||||||
|
|
||||||
archive.Close();
|
archive.Close();
|
||||||
|
|
||||||
|
if (serializedPrims.Equals(string.Empty))
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat("[ARCHIVER]: Archive did not contain a {0} file", ArchiveConstants.PRIMS_PATH);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reload serialized prims
|
||||||
|
m_log.InfoFormat("[ARCHIVER]: Loading prim data");
|
||||||
|
|
||||||
|
//m_scene.LoadPrimsFromXml2(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ using libsecondlife;
|
||||||
using log4net;
|
using log4net;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
|
|
||||||
namespace OpenSim.Region.Environment
|
namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Method called when all the necessary assets for an archive request have been received.
|
/// Method called when all the necessary assets for an archive request have been received.
|
||||||
|
@ -103,7 +103,7 @@ namespace OpenSim.Region.Environment
|
||||||
|
|
||||||
TarArchiveWriter archive = new TarArchiveWriter();
|
TarArchiveWriter archive = new TarArchiveWriter();
|
||||||
|
|
||||||
archive.AddFile("prims.xml", m_serializedEntities);
|
archive.AddFile(ArchiveConstants.PRIMS_PATH, m_serializedEntities);
|
||||||
|
|
||||||
// It appears that gtar, at least, doesn't need the intermediate directory entries in the tar
|
// It appears that gtar, at least, doesn't need the intermediate directory entries in the tar
|
||||||
//archive.AddDir("assets");
|
//archive.AddDir("assets");
|
||||||
|
@ -112,7 +112,7 @@ namespace OpenSim.Region.Environment
|
||||||
{
|
{
|
||||||
if (assets[uuid] != null)
|
if (assets[uuid] != null)
|
||||||
{
|
{
|
||||||
archive.AddFile("assets/" + uuid.ToString() + ".jp2", assets[uuid].Data);
|
archive.AddFile(ArchiveConstants.ASSETS_PATH + uuid.ToString() + ".jp2", assets[uuid].Data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
|
||||||
namespace OpenSim.Region.Environment.Modules.World.Archiver
|
namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
|
@ -39,13 +40,18 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
protected static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding();
|
protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Binary reader for the underlying stream
|
/// Binary reader for the underlying stream
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected BinaryReader m_br;
|
protected BinaryReader m_br;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Used to trim off null chars
|
||||||
|
/// </summary>
|
||||||
|
protected char[] m_nullCharArray = new char[] { '\0' };
|
||||||
|
|
||||||
public TarArchiveReader(string archivePath)
|
public TarArchiveReader(string archivePath)
|
||||||
{
|
{
|
||||||
m_br = new BinaryReader(new FileStream(archivePath, FileMode.Open));
|
m_br = new BinaryReader(new FileStream(archivePath, FileMode.Open));
|
||||||
|
@ -109,6 +115,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
byte[] header = m_br.ReadBytes(512);
|
byte[] header = m_br.ReadBytes(512);
|
||||||
|
|
||||||
tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100);
|
tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100);
|
||||||
|
tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray);
|
||||||
tarHeader.FileSize = ConvertOctalBytesToDecimal(header, 124, 11);
|
tarHeader.FileSize = ConvertOctalBytesToDecimal(header, 124, 11);
|
||||||
|
|
||||||
return tarHeader;
|
return tarHeader;
|
||||||
|
|
Loading…
Reference in New Issue