aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-07-12 18:54:21 +0000
committerJustin Clarke Casey2008-07-12 18:54:21 +0000
commit4e7dd0d9193155b22f0d8da1e0758b39652f4c41 (patch)
treefd62e8770c678aac5829791c01be31161aa184e3
parentPatch #9146 (No Mantis) (diff)
downloadopensim-SC-4e7dd0d9193155b22f0d8da1e0758b39652f4c41.zip
opensim-SC-4e7dd0d9193155b22f0d8da1e0758b39652f4c41.tar.gz
opensim-SC-4e7dd0d9193155b22f0d8da1e0758b39652f4c41.tar.bz2
opensim-SC-4e7dd0d9193155b22f0d8da1e0758b39652f4c41.tar.xz
* Start compressing archives
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs2
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs7
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs3
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs42
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveWriter.cs12
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs2
6 files changed, 32 insertions, 36 deletions
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 37daf88..c6061e1 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -68,7 +68,7 @@ namespace OpenSim
68 /// <summary> 68 /// <summary>
69 /// The file use to load and save an opensim archive if none has been specified 69 /// The file use to load and save an opensim archive if none has been specified
70 /// </summary> 70 /// </summary>
71 protected const string DEFAULT_OAR_BACKUP_FILENAME = "scene.oar.tar"; 71 protected const string DEFAULT_OAR_BACKUP_FILENAME = "scene_oar.tar.gz";
72 72
73 public string m_physicsEngine; 73 public string m_physicsEngine;
74 public string m_meshEngineName; 74 public string m_meshEngineName;
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
index 0f179f4..0e37197 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
@@ -32,6 +32,7 @@ using OpenSim.Region.Environment.Modules.World.Terrain;
32using System; 32using System;
33using System.Collections.Generic; 33using System.Collections.Generic;
34using System.IO; 34using System.IO;
35using System.IO.Compression;
35using System.Reflection; 36using System.Reflection;
36using System.Xml; 37using System.Xml;
37using libsecondlife; 38using libsecondlife;
@@ -60,8 +61,10 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
60 } 61 }
61 62
62 protected void DearchiveRegion() 63 protected void DearchiveRegion()
63 { 64 {
64 TarArchiveReader archive = new TarArchiveReader(m_loadPath); 65 TarArchiveReader archive
66 = new TarArchiveReader(
67 new GZipStream(new FileStream(m_loadPath, FileMode.Open), CompressionMode.Decompress));
65 //AssetsDearchiver dearchiver = new AssetsDearchiver(m_scene.AssetCache); 68 //AssetsDearchiver dearchiver = new AssetsDearchiver(m_scene.AssetCache);
66 69
67 List<string> serialisedSceneObjects = new List<string>(); 70 List<string> serialisedSceneObjects = new List<string>();
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs
index f8c8b73..e980650 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequestExecution.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.IO.Compression;
31using System.Reflection; 32using System.Reflection;
32using System.Xml; 33using System.Xml;
33using libsecondlife; 34using libsecondlife;
@@ -110,7 +111,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
110 AssetsArchiver assetsArchiver = new AssetsArchiver(assets); 111 AssetsArchiver assetsArchiver = new AssetsArchiver(assets);
111 assetsArchiver.Archive(archive); 112 assetsArchiver.Archive(archive);
112 113
113 archive.WriteTar(m_savePath); 114 archive.WriteTar(new GZipStream(new FileStream(m_savePath, FileMode.Create), CompressionMode.Compress));
114 115
115 m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive {0}", m_savePath); 116 m_log.InfoFormat("[ARCHIVER]: Wrote out OpenSimulator archive {0}", m_savePath);
116 } 117 }
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs
index 463e172..67f27b8 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs
@@ -52,23 +52,13 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
52 /// </summary> 52 /// </summary>
53 protected char[] m_nullCharArray = new char[] { '\0' }; 53 protected char[] m_nullCharArray = new char[] { '\0' };
54 54
55 public TarArchiveReader(string archivePath)
56 {
57 m_br = new BinaryReader(new FileStream(archivePath, FileMode.Open));
58 }
59
60 /// <summary> 55 /// <summary>
61 /// Are we at the end of the archive? 56 /// Generate a tar reader which reads from the given stream.
62 /// </summary> 57 /// </summary>
63 /// <returns></returns> 58 /// <param name="s"></param>
64 public bool AtEof() 59 public TarArchiveReader(Stream s)
65 { 60 {
66 // If we've reached the end of the archive we'll be in null block territory, which means 61 m_br = new BinaryReader(s);
67 // the next byte will be 0
68 if (m_br.PeekChar() == 0)
69 return true;
70
71 return false;
72 } 62 }
73 63
74 /// <summary> 64 /// <summary>
@@ -79,11 +69,11 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
79 public byte[] ReadEntry(out string filePath) 69 public byte[] ReadEntry(out string filePath)
80 { 70 {
81 filePath = String.Empty; 71 filePath = String.Empty;
82 72
83 if (AtEof())
84 return null;
85
86 TarHeader header = ReadHeader(); 73 TarHeader header = ReadHeader();
74
75 if (null == header)
76 return null;
87 77
88 filePath = header.FilePath; 78 filePath = header.FilePath;
89 byte[] data = m_br.ReadBytes(header.FileSize); 79 byte[] data = m_br.ReadBytes(header.FileSize);
@@ -105,14 +95,18 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
105 95
106 /// <summary> 96 /// <summary>
107 /// Read the next 512 byte chunk of data as a tar header. 97 /// Read the next 512 byte chunk of data as a tar header.
108 /// This method assumes we are not at the end of the archive
109 /// </summary> 98 /// </summary>
110 /// <returns>A tar header struct.</returns> 99 /// <returns>A tar header struct. null if we have reached the end of the archive.</returns>
111 protected TarHeader ReadHeader() 100 protected TarHeader ReadHeader()
112 { 101 {
113 TarHeader tarHeader = new TarHeader();
114
115 byte[] header = m_br.ReadBytes(512); 102 byte[] header = m_br.ReadBytes(512);
103
104 // If we've reached the end of the archive we'll be in null block territory, which means
105 // the next byte will be 0
106 if (header[0] == 0)
107 return null;
108
109 TarHeader tarHeader = new TarHeader();
116 110
117 tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100); 111 tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100);
118 tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray); 112 tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray);
@@ -147,7 +141,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
147 } 141 }
148 } 142 }
149 143
150 public struct TarHeader 144 public class TarHeader
151 { 145 {
152 public string FilePath; 146 public string FilePath;
153 public int FileSize; 147 public int FileSize;
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveWriter.cs b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveWriter.cs
index 1301eb3..afb0a91 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveWriter.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveWriter.cs
@@ -79,21 +79,19 @@ namespace OpenSim.Region.Environment
79 } 79 }
80 80
81 /// <summary> 81 /// <summary>
82 /// Write the raw tar archive data to a file 82 /// Write the raw tar archive data to a stream. The stream will be closed on completion.
83 /// </summary> 83 /// </summary>
84 /// <param name="s">Stream to which to write the data</param>
84 /// <returns></returns> 85 /// <returns></returns>
85 public void WriteTar(string archivePath) 86 public void WriteTar(Stream s)
86 { 87 {
87 BinaryWriter bw = new BinaryWriter(new FileStream(archivePath, FileMode.Create)); 88 BinaryWriter bw = new BinaryWriter(s);
88 89
89 foreach (string filePath in m_files.Keys) 90 foreach (string filePath in m_files.Keys)
90 { 91 {
91 byte[] header = new byte[512]; 92 byte[] header = new byte[512];
92 byte[] data = m_files[filePath]; 93 byte[] data = m_files[filePath];
93 94
94 //string filePath = "test.txt";
95 //byte[] data = m_asciiEncoding.GetBytes("hello\n");
96
97 // file path field (100) 95 // file path field (100)
98 byte[] nameBytes = m_asciiEncoding.GetBytes(filePath); 96 byte[] nameBytes = m_asciiEncoding.GetBytes(filePath);
99 int nameSize = (nameBytes.Length >= 100) ? 100 : nameBytes.Length; 97 int nameSize = (nameBytes.Length >= 100) ? 100 : nameBytes.Length;
@@ -149,7 +147,6 @@ namespace OpenSim.Region.Environment
149 m_log.DebugFormat("[TAR ARCHIVE WRITER]: Decimal header checksum is {0}", checksum); 147 m_log.DebugFormat("[TAR ARCHIVE WRITER]: Decimal header checksum is {0}", checksum);
150 148
151 byte[] checkSumBytes = ConvertDecimalToPaddedOctalBytes(checksum, 6); 149 byte[] checkSumBytes = ConvertDecimalToPaddedOctalBytes(checksum, 6);
152 //byte[] checkSumBytes = m_asciiEncoding.GetBytes("007520");
153 150
154 Array.Copy(checkSumBytes, 0, header, 148, 6); 151 Array.Copy(checkSumBytes, 0, header, 148, 6);
155 152
@@ -176,6 +173,7 @@ namespace OpenSim.Region.Environment
176 byte[] finalZeroPadding = new byte[1024]; 173 byte[] finalZeroPadding = new byte[1024];
177 bw.Write(finalZeroPadding); 174 bw.Write(finalZeroPadding);
178 175
176 bw.Flush();
179 bw.Close(); 177 bw.Close();
180 } 178 }
181 179
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index eafb882..f2c94c8 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -2014,7 +2014,7 @@ namespace OpenSim.Region.Environment.Scenes
2014 { 2014 {
2015 foreach (SceneObjectPart parts in m_parts.Values) 2015 foreach (SceneObjectPart parts in m_parts.Values)
2016 { 2016 {
2017 if(part.Scale.X > 10.0 || part.Scale.Y > 10.0 || part.Scale.Z > 10.0) 2017 if (part.Scale.X > 10.0 || part.Scale.Y > 10.0 || part.Scale.Z > 10.0)
2018 { 2018 {
2019 data[47] = 0; // Reset physics 2019 data[47] = 0; // Reset physics
2020 break; 2020 break;