backport iar version checking
parent
ce39ec9005
commit
2db53df6fa
|
@ -51,6 +51,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The maximum major version of archive that we can read. Minor versions shouldn't need a max number since version
|
||||||
|
/// bumps here should be compatible.
|
||||||
|
/// </summary>
|
||||||
|
public static int MAX_MAJOR_VERSION = 0;
|
||||||
|
|
||||||
protected TarArchiveReader archive;
|
protected TarArchiveReader archive;
|
||||||
|
|
||||||
private CachedUserInfo m_userInfo;
|
private CachedUserInfo m_userInfo;
|
||||||
|
@ -126,7 +132,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
{
|
{
|
||||||
while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
|
while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
|
||||||
{
|
{
|
||||||
if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
|
if (filePath == ArchiveConstants.CONTROL_FILE_PATH)
|
||||||
|
{
|
||||||
|
LoadControlFile(filePath, data);
|
||||||
|
}
|
||||||
|
else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
|
||||||
{
|
{
|
||||||
if (LoadAsset(filePath, data))
|
if (LoadAsset(filePath, data))
|
||||||
successfulAssetRestores++;
|
successfulAssetRestores++;
|
||||||
|
@ -432,5 +442,44 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Load control file
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
protected void LoadControlFile(string path, byte[] data)
|
||||||
|
{
|
||||||
|
int majorVersion = -1;
|
||||||
|
int minorVersion = -1;
|
||||||
|
string version = "ERROR";
|
||||||
|
|
||||||
|
NameTable nt = new NameTable();
|
||||||
|
XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
|
||||||
|
XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);
|
||||||
|
XmlTextReader xtr = new XmlTextReader(Encoding.ASCII.GetString(data), XmlNodeType.Document, context);
|
||||||
|
while (xtr.Read())
|
||||||
|
{
|
||||||
|
if (xtr.NodeType == XmlNodeType.Element)
|
||||||
|
{
|
||||||
|
if (xtr.Name.ToString() == "archive")
|
||||||
|
{
|
||||||
|
majorVersion = int.Parse(xtr["major_version"]);
|
||||||
|
minorVersion = int.Parse(xtr["minor_version"]);
|
||||||
|
version = string.Format("{0}.{1}", majorVersion, minorVersion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (majorVersion > MAX_MAJOR_VERSION)
|
||||||
|
{
|
||||||
|
throw new Exception(
|
||||||
|
string.Format(
|
||||||
|
"The IAR you are trying to load has major version number of {0} but this version of OpenSim can only load IARs with major version number {1} and below",
|
||||||
|
majorVersion, MAX_MAJOR_VERSION));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue