aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorDr Scofield2009-01-22 16:43:09 +0000
committerDr Scofield2009-01-22 16:43:09 +0000
commit7e08d7da157294640e72c22a521ae233bad2b84c (patch)
treea7b718ee1384cd3a1e3cfebac21c5d56c150c794 /OpenSim/Region
parentUpdate svn properties, minor formatting cleanup. (diff)
downloadopensim-SC_OLD-7e08d7da157294640e72c22a521ae233bad2b84c.zip
opensim-SC_OLD-7e08d7da157294640e72c22a521ae233bad2b84c.tar.gz
opensim-SC_OLD-7e08d7da157294640e72c22a521ae233bad2b84c.tar.bz2
opensim-SC_OLD-7e08d7da157294640e72c22a521ae233bad2b84c.tar.xz
From: Christopher Yeoh <yeohc@au1.ibm.com>
this patch makes load-oar a bit more tolerant to irrelevant differences in the oar file format. Directory entries are now ignored rather than trying to interpret them as files they hold which results in the load-oar failing. This change makes it easier to manually modify oar files.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs8
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs10
-rw-r--r--OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs48
3 files changed, 59 insertions, 7 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index eab4461..e15a232 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -187,9 +187,13 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver
187 new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress)); 187 new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress));
188 188
189 byte[] data; 189 byte[] data;
190 while ((data = archive.ReadEntry(out filePath)) != null) 190 TarArchiveReader.TarEntryType entryType;
191 while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
191 { 192 {
192 if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH)) 193 if (entryType==TarArchiveReader.TarEntryType.TYPE_DIRECTORY) {
194 m_log.WarnFormat("[ARCHIVER]: Ignoring directory entry {0}",
195 filePath);
196 } else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
193 { 197 {
194 if (LoadAsset(filePath, data)) 198 if (LoadAsset(filePath, data))
195 successfulAssetRestores++; 199 successfulAssetRestores++;
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
index a5b5917..73fd916 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs
@@ -88,12 +88,16 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
88 int failedAssetRestores = 0; 88 int failedAssetRestores = 0;
89 89
90 byte[] data; 90 byte[] data;
91 while ((data = archive.ReadEntry(out filePath)) != null) 91 TarArchiveReader.TarEntryType entryType;
92 while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
92 { 93 {
93 //m_log.DebugFormat( 94 //m_log.DebugFormat(
94 // "[ARCHIVER]: Successfully read {0} ({1} bytes)}", filePath, data.Length); 95 // "[ARCHIVER]: Successfully read {0} ({1} bytes)}", filePath, data.Length);
95 96 if (entryType==TarArchiveReader.TarEntryType.TYPE_DIRECTORY) {
96 if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH)) 97 m_log.WarnFormat("[ARCHIVER]: Ignoring directory entry {0}",
98 filePath);
99 }
100 else if (filePath.StartsWith(ArchiveConstants.OBJECTS_PATH))
97 { 101 {
98 serialisedSceneObjects.Add(m_asciiEncoding.GetString(data)); 102 serialisedSceneObjects.Add(m_asciiEncoding.GetString(data));
99 } 103 }
diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs
index 4e000cc..5d308f0 100644
--- a/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs
+++ b/OpenSim/Region/Environment/Modules/World/Archiver/TarArchiveReader.cs
@@ -39,6 +39,18 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
39 public class TarArchiveReader 39 public class TarArchiveReader
40 { 40 {
41 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 41 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42 public enum TarEntryType
43 {
44 TYPE_UNKNOWN = 0,
45 TYPE_NORMAL_FILE = 1,
46 TYPE_HARD_LINK = 2,
47 TYPE_SYMBOLIC_LINK = 3,
48 TYPE_CHAR_SPECIAL = 4,
49 TYPE_BLOCK_SPECIAL = 5,
50 TYPE_DIRECTORY = 6,
51 TYPE_FIFO = 7,
52 TYPE_CONTIGUOUS_FILE = 8,
53 }
42 54
43 protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding(); 55 protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
44 56
@@ -66,15 +78,16 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
66 /// </summary> 78 /// </summary>
67 /// <param name="filePath"></param> 79 /// <param name="filePath"></param>
68 /// <returns>the data for the entry. Returns null if there are no more entries</returns> 80 /// <returns>the data for the entry. Returns null if there are no more entries</returns>
69 public byte[] ReadEntry(out string filePath) 81 public byte[] ReadEntry(out string filePath, out TarEntryType entryType)
70 { 82 {
71 filePath = String.Empty; 83 filePath = String.Empty;
72 84 entryType = TarEntryType.TYPE_UNKNOWN;
73 TarHeader header = ReadHeader(); 85 TarHeader header = ReadHeader();
74 86
75 if (null == header) 87 if (null == header)
76 return null; 88 return null;
77 89
90 entryType = header.EntryType;
78 filePath = header.FilePath; 91 filePath = header.FilePath;
79 byte[] data = m_br.ReadBytes(header.FileSize); 92 byte[] data = m_br.ReadBytes(header.FileSize);
80 93
@@ -112,6 +125,36 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
112 tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray); 125 tarHeader.FilePath = tarHeader.FilePath.Trim(m_nullCharArray);
113 tarHeader.FileSize = ConvertOctalBytesToDecimal(header, 124, 11); 126 tarHeader.FileSize = ConvertOctalBytesToDecimal(header, 124, 11);
114 127
128 switch (header[156])
129 {
130 case 0:
131 tarHeader.EntryType = TarEntryType.TYPE_NORMAL_FILE;
132 break;
133 case (byte)'0':
134 tarHeader.EntryType = TarEntryType.TYPE_NORMAL_FILE;
135 break;
136 case (byte)'1':
137 tarHeader.EntryType = TarEntryType.TYPE_HARD_LINK;
138 break;
139 case (byte)'2':
140 tarHeader.EntryType = TarEntryType.TYPE_SYMBOLIC_LINK;
141 break;
142 case (byte)'3':
143 tarHeader.EntryType = TarEntryType.TYPE_CHAR_SPECIAL;
144 break;
145 case (byte)'4':
146 tarHeader.EntryType = TarEntryType.TYPE_BLOCK_SPECIAL;
147 break;
148 case (byte)'5':
149 tarHeader.EntryType = TarEntryType.TYPE_DIRECTORY;
150 break;
151 case (byte)'6':
152 tarHeader.EntryType = TarEntryType.TYPE_FIFO;
153 break;
154 case (byte)'7':
155 tarHeader.EntryType = TarEntryType.TYPE_CONTIGUOUS_FILE;
156 break;
157 }
115 return tarHeader; 158 return tarHeader;
116 } 159 }
117 160
@@ -145,5 +188,6 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
145 { 188 {
146 public string FilePath; 189 public string FilePath;
147 public int FileSize; 190 public int FileSize;
191 public TarArchiveReader.TarEntryType EntryType;
148 } 192 }
149} 193}