* Start compressing archives
parent
4ff529bdaf
commit
4e7dd0d919
|
@ -68,7 +68,7 @@ namespace OpenSim
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The file use to load and save an opensim archive if none has been specified
|
/// The file use to load and save an opensim archive if none has been specified
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected const string DEFAULT_OAR_BACKUP_FILENAME = "scene.oar.tar";
|
protected const string DEFAULT_OAR_BACKUP_FILENAME = "scene_oar.tar.gz";
|
||||||
|
|
||||||
public string m_physicsEngine;
|
public string m_physicsEngine;
|
||||||
public string m_meshEngineName;
|
public string m_meshEngineName;
|
||||||
|
|
|
@ -32,6 +32,7 @@ using OpenSim.Region.Environment.Modules.World.Terrain;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.IO.Compression;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using libsecondlife;
|
using libsecondlife;
|
||||||
|
@ -60,8 +61,10 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void DearchiveRegion()
|
protected void DearchiveRegion()
|
||||||
{
|
{
|
||||||
TarArchiveReader archive = new TarArchiveReader(m_loadPath);
|
TarArchiveReader archive
|
||||||
|
= new TarArchiveReader(
|
||||||
|
new GZipStream(new FileStream(m_loadPath, FileMode.Open), CompressionMode.Decompress));
|
||||||
//AssetsDearchiver dearchiver = new AssetsDearchiver(m_scene.AssetCache);
|
//AssetsDearchiver dearchiver = new AssetsDearchiver(m_scene.AssetCache);
|
||||||
|
|
||||||
List<string> serialisedSceneObjects = new List<string>();
|
List<string> serialisedSceneObjects = new List<string>();
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.IO.Compression;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using libsecondlife;
|
using libsecondlife;
|
||||||
|
@ -110,7 +111,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
AssetsArchiver assetsArchiver = new AssetsArchiver(assets);
|
AssetsArchiver assetsArchiver = new AssetsArchiver(assets);
|
||||||
assetsArchiver.Archive(archive);
|
assetsArchiver.Archive(archive);
|
||||||
|
|
||||||
archive.WriteTar(m_savePath);
|
archive.WriteTar(new GZipStream(new FileStream(m_savePath, FileMode.Create), CompressionMode.Compress));
|
||||||
|
|
||||||
m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive {0}", m_savePath);
|
m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive {0}", m_savePath);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,23 +52,13 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected char[] m_nullCharArray = new char[] { '\0' };
|
protected char[] m_nullCharArray = new char[] { '\0' };
|
||||||
|
|
||||||
public TarArchiveReader(string archivePath)
|
|
||||||
{
|
|
||||||
m_br = new BinaryReader(new FileStream(archivePath, FileMode.Open));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Are we at the end of the archive?
|
/// Generate a tar reader which reads from the given stream.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <param name="s"></param>
|
||||||
public bool AtEof()
|
public TarArchiveReader(Stream s)
|
||||||
{
|
{
|
||||||
// If we've reached the end of the archive we'll be in null block territory, which means
|
m_br = new BinaryReader(s);
|
||||||
// the next byte will be 0
|
|
||||||
if (m_br.PeekChar() == 0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -79,11 +69,11 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
public byte[] ReadEntry(out string filePath)
|
public byte[] ReadEntry(out string filePath)
|
||||||
{
|
{
|
||||||
filePath = String.Empty;
|
filePath = String.Empty;
|
||||||
|
|
||||||
if (AtEof())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
TarHeader header = ReadHeader();
|
TarHeader header = ReadHeader();
|
||||||
|
|
||||||
|
if (null == header)
|
||||||
|
return null;
|
||||||
|
|
||||||
filePath = header.FilePath;
|
filePath = header.FilePath;
|
||||||
byte[] data = m_br.ReadBytes(header.FileSize);
|
byte[] data = m_br.ReadBytes(header.FileSize);
|
||||||
|
@ -105,14 +95,18 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Read the next 512 byte chunk of data as a tar header.
|
/// Read the next 512 byte chunk of data as a tar header.
|
||||||
/// This method assumes we are not at the end of the archive
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A tar header struct.</returns>
|
/// <returns>A tar header struct. null if we have reached the end of the archive.</returns>
|
||||||
protected TarHeader ReadHeader()
|
protected TarHeader ReadHeader()
|
||||||
{
|
{
|
||||||
TarHeader tarHeader = new TarHeader();
|
|
||||||
|
|
||||||
byte[] header = m_br.ReadBytes(512);
|
byte[] header = m_br.ReadBytes(512);
|
||||||
|
|
||||||
|
// If we've reached the end of the archive we'll be in null block territory, which means
|
||||||
|
// the next byte will be 0
|
||||||
|
if (header[0] == 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
TarHeader tarHeader = new TarHeader();
|
||||||
|
|
||||||
tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100);
|
tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100);
|
||||||
tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray);
|
tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray);
|
||||||
|
@ -147,7 +141,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct TarHeader
|
public class TarHeader
|
||||||
{
|
{
|
||||||
public string FilePath;
|
public string FilePath;
|
||||||
public int FileSize;
|
public int FileSize;
|
||||||
|
|
|
@ -79,21 +79,19 @@ namespace OpenSim.Region.Environment
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Write the raw tar archive data to a file
|
/// Write the raw tar archive data to a stream. The stream will be closed on completion.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="s">Stream to which to write the data</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public void WriteTar(string archivePath)
|
public void WriteTar(Stream s)
|
||||||
{
|
{
|
||||||
BinaryWriter bw = new BinaryWriter(new FileStream(archivePath, FileMode.Create));
|
BinaryWriter bw = new BinaryWriter(s);
|
||||||
|
|
||||||
foreach (string filePath in m_files.Keys)
|
foreach (string filePath in m_files.Keys)
|
||||||
{
|
{
|
||||||
byte[] header = new byte[512];
|
byte[] header = new byte[512];
|
||||||
byte[] data = m_files[filePath];
|
byte[] data = m_files[filePath];
|
||||||
|
|
||||||
//string filePath = "test.txt";
|
|
||||||
//byte[] data = m_asciiEncoding.GetBytes("hello\n");
|
|
||||||
|
|
||||||
// file path field (100)
|
// file path field (100)
|
||||||
byte[] nameBytes = m_asciiEncoding.GetBytes(filePath);
|
byte[] nameBytes = m_asciiEncoding.GetBytes(filePath);
|
||||||
int nameSize = (nameBytes.Length >= 100) ? 100 : nameBytes.Length;
|
int nameSize = (nameBytes.Length >= 100) ? 100 : nameBytes.Length;
|
||||||
|
@ -149,7 +147,6 @@ namespace OpenSim.Region.Environment
|
||||||
m_log.DebugFormat("[TAR ARCHIVE WRITER]: Decimal header checksum is {0}", checksum);
|
m_log.DebugFormat("[TAR ARCHIVE WRITER]: Decimal header checksum is {0}", checksum);
|
||||||
|
|
||||||
byte[] checkSumBytes = ConvertDecimalToPaddedOctalBytes(checksum, 6);
|
byte[] checkSumBytes = ConvertDecimalToPaddedOctalBytes(checksum, 6);
|
||||||
//byte[] checkSumBytes = m_asciiEncoding.GetBytes("007520");
|
|
||||||
|
|
||||||
Array.Copy(checkSumBytes, 0, header, 148, 6);
|
Array.Copy(checkSumBytes, 0, header, 148, 6);
|
||||||
|
|
||||||
|
@ -176,6 +173,7 @@ namespace OpenSim.Region.Environment
|
||||||
byte[] finalZeroPadding = new byte[1024];
|
byte[] finalZeroPadding = new byte[1024];
|
||||||
bw.Write(finalZeroPadding);
|
bw.Write(finalZeroPadding);
|
||||||
|
|
||||||
|
bw.Flush();
|
||||||
bw.Close();
|
bw.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2014,7 +2014,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
foreach (SceneObjectPart parts in m_parts.Values)
|
foreach (SceneObjectPart parts in m_parts.Values)
|
||||||
{
|
{
|
||||||
if(part.Scale.X > 10.0 || part.Scale.Y > 10.0 || part.Scale.Z > 10.0)
|
if (part.Scale.X > 10.0 || part.Scale.Y > 10.0 || part.Scale.Z > 10.0)
|
||||||
{
|
{
|
||||||
data[47] = 0; // Reset physics
|
data[47] = 0; // Reset physics
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue