diff options
Diffstat (limited to 'OpenSim')
5 files changed, 79 insertions, 6 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs index befa89f..a7abfb4 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs | |||
@@ -861,4 +861,4 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
861 | m_tcp.Close(); | 861 | m_tcp.Close(); |
862 | } | 862 | } |
863 | } | 863 | } |
864 | } \ No newline at end of file | 864 | } |
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs new file mode 100644 index 0000000..7df6033 --- /dev/null +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveConstants.cs | |||
@@ -0,0 +1,45 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | namespace OpenSim.Region.Environment.Modules.World.Archiver | ||
29 | { | ||
30 | /// <summary> | ||
31 | /// Constants for the archiving module | ||
32 | /// </summary> | ||
33 | public class ArchiveConstants | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// Path for the assets held in an archive | ||
37 | /// </summary> | ||
38 | public static readonly string ASSETS_PATH = "assets/"; | ||
39 | |||
40 | /// <summary> | ||
41 | /// Path for the prims file | ||
42 | /// </summary> | ||
43 | public static readonly string PRIMS_PATH = "prims.xml"; | ||
44 | } | ||
45 | } | ||
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs index 268b9b5..6ad11ee 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Region.Environment.Scenes; | 28 | using OpenSim.Region.Environment.Scenes; |
29 | using System; | ||
29 | using System.Reflection; | 30 | using System.Reflection; |
30 | using log4net; | 31 | using log4net; |
31 | 32 | ||
@@ -38,6 +39,8 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
38 | { | 39 | { |
39 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 40 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
40 | 41 | ||
42 | protected static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding(); | ||
43 | |||
41 | private Scene m_scene; | 44 | private Scene m_scene; |
42 | private string m_loadPath; | 45 | private string m_loadPath; |
43 | 46 | ||
@@ -53,6 +56,8 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
53 | { | 56 | { |
54 | TarArchiveReader archive = new TarArchiveReader(m_loadPath); | 57 | TarArchiveReader archive = new TarArchiveReader(m_loadPath); |
55 | 58 | ||
59 | string serializedPrims = string.Empty; | ||
60 | |||
56 | // Just test for now by reading first file | 61 | // Just test for now by reading first file |
57 | string filePath = "ERROR"; | 62 | string filePath = "ERROR"; |
58 | 63 | ||
@@ -60,11 +65,27 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
60 | while ((data = archive.ReadEntry(out filePath)) != null) | 65 | while ((data = archive.ReadEntry(out filePath)) != null) |
61 | { | 66 | { |
62 | m_log.DebugFormat("[ARCHIVER]: Successfully read {0} ({1} bytes) from archive {2}", filePath, data.Length, m_loadPath); | 67 | m_log.DebugFormat("[ARCHIVER]: Successfully read {0} ({1} bytes) from archive {2}", filePath, data.Length, m_loadPath); |
68 | |||
69 | if (filePath.Equals(ArchiveConstants.PRIMS_PATH)) | ||
70 | { | ||
71 | serializedPrims = m_asciiEncoding.GetString(data); | ||
72 | } | ||
63 | } | 73 | } |
64 | 74 | ||
65 | m_log.DebugFormat("[ARCHIVER]: Reached end of archive"); | 75 | m_log.DebugFormat("[ARCHIVER]: Reached end of archive"); |
66 | 76 | ||
67 | archive.Close(); | 77 | archive.Close(); |
78 | |||
79 | if (serializedPrims.Equals(string.Empty)) | ||
80 | { | ||
81 | m_log.ErrorFormat("[ARCHIVER]: Archive did not contain a {0} file", ArchiveConstants.PRIMS_PATH); | ||
82 | return; | ||
83 | } | ||
84 | |||
85 | // Reload serialized prims | ||
86 | m_log.InfoFormat("[ARCHIVER]: Loading prim data"); | ||
87 | |||
88 | //m_scene.LoadPrimsFromXml2( | ||
68 | } | 89 | } |
69 | } | 90 | } |
70 | } | 91 | } |
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs index 576286d..d936df5 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveWriteRequest.cs | |||
@@ -36,7 +36,7 @@ using libsecondlife; | |||
36 | using log4net; | 36 | using log4net; |
37 | using Nini.Config; | 37 | using Nini.Config; |
38 | 38 | ||
39 | namespace OpenSim.Region.Environment | 39 | namespace OpenSim.Region.Environment.Modules.World.Archiver |
40 | { | 40 | { |
41 | /// <summary> | 41 | /// <summary> |
42 | /// Method called when all the necessary assets for an archive request have been received. | 42 | /// Method called when all the necessary assets for an archive request have been received. |
@@ -103,7 +103,7 @@ namespace OpenSim.Region.Environment | |||
103 | 103 | ||
104 | TarArchiveWriter archive = new TarArchiveWriter(); | 104 | TarArchiveWriter archive = new TarArchiveWriter(); |
105 | 105 | ||
106 | archive.AddFile("prims.xml", m_serializedEntities); | 106 | archive.AddFile(ArchiveConstants.PRIMS_PATH, m_serializedEntities); |
107 | 107 | ||
108 | // It appears that gtar, at least, doesn't need the intermediate directory entries in the tar | 108 | // It appears that gtar, at least, doesn't need the intermediate directory entries in the tar |
109 | //archive.AddDir("assets"); | 109 | //archive.AddDir("assets"); |
@@ -112,7 +112,7 @@ namespace OpenSim.Region.Environment | |||
112 | { | 112 | { |
113 | if (assets[uuid] != null) | 113 | if (assets[uuid] != null) |
114 | { | 114 | { |
115 | archive.AddFile("assets/" + uuid.ToString() + ".jp2", assets[uuid].Data); | 115 | archive.AddFile(ArchiveConstants.ASSETS_PATH + uuid.ToString() + ".jp2", assets[uuid].Data); |
116 | } | 116 | } |
117 | else | 117 | else |
118 | { | 118 | { |
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs index aacae95..b199d5f 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Text; | ||
31 | using log4net; | 32 | using log4net; |
32 | 33 | ||
33 | namespace OpenSim.Region.Environment.Modules.World.Archiver | 34 | namespace OpenSim.Region.Environment.Modules.World.Archiver |
@@ -39,13 +40,18 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
39 | { | 40 | { |
40 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
41 | 42 | ||
42 | protected static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding(); | 43 | protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding(); |
43 | 44 | ||
44 | /// <summary> | 45 | /// <summary> |
45 | /// Binary reader for the underlying stream | 46 | /// Binary reader for the underlying stream |
46 | /// </summary> | 47 | /// </summary> |
47 | protected BinaryReader m_br; | 48 | protected BinaryReader m_br; |
48 | 49 | ||
50 | /// <summary> | ||
51 | /// Used to trim off null chars | ||
52 | /// </summary> | ||
53 | protected char[] m_nullCharArray = new char[] { '\0' }; | ||
54 | |||
49 | public TarArchiveReader(string archivePath) | 55 | public TarArchiveReader(string archivePath) |
50 | { | 56 | { |
51 | m_br = new BinaryReader(new FileStream(archivePath, FileMode.Open)); | 57 | m_br = new BinaryReader(new FileStream(archivePath, FileMode.Open)); |
@@ -109,6 +115,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver | |||
109 | byte[] header = m_br.ReadBytes(512); | 115 | byte[] header = m_br.ReadBytes(512); |
110 | 116 | ||
111 | tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100); | 117 | tarHeader.FilePath = m_asciiEncoding.GetString(header, 0, 100); |
118 | tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray); | ||
112 | tarHeader.FileSize = ConvertOctalBytesToDecimal(header, 124, 11); | 119 | tarHeader.FileSize = ConvertOctalBytesToDecimal(header, 124, 11); |
113 | 120 | ||
114 | return tarHeader; | 121 | return tarHeader; |