Move ArchiveConstants to OpenSim.Framework.Archive
- move a couple constants from InventoryArchiveConstants to ArchiveConstants, now only one of these is needed - change InventoryArchiveConstants references to ArchiveConstants - remove InventoryArchive AssetInventoryServer plugin dependency on OpenSim.Region.CodeModules - trim trailing whitespace0.6.5-rc1
parent
f784620780
commit
7b2977d625
|
@ -28,7 +28,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
|
|
||||||
namespace OpenSim.Region.CoreModules.World.Archiver
|
namespace OpenSim.Framework.Archive
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constants for the archiving module
|
/// Constants for the archiving module
|
||||||
|
@ -45,6 +45,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly string ASSETS_PATH = "assets/";
|
public static readonly string ASSETS_PATH = "assets/";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Path for the inventory data
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string INVENTORY_PATH = "inventory/";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Path for the prims file
|
/// Path for the prims file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -54,7 +59,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||||
/// Path for terrains. Technically these may be assets, but I think it's quite nice to split them out.
|
/// Path for terrains. Technically these may be assets, but I think it's quite nice to split them out.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly string TERRAINS_PATH = "terrains/";
|
public static readonly string TERRAINS_PATH = "terrains/";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Path for region settings.
|
/// Path for region settings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -65,6 +70,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly string ASSET_EXTENSION_SEPARATOR = "_";
|
public static readonly string ASSET_EXTENSION_SEPARATOR = "_";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Used to separate components in an inventory node name
|
||||||
|
/// </summary>
|
||||||
|
public static readonly string INVENTORY_NODE_NAME_COMPONENT_SEPARATOR = "__";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Extensions used for asset types in the archive
|
/// Extensions used for asset types in the archive
|
||||||
/// </summary>
|
/// </summary>
|
|
@ -35,7 +35,6 @@ using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Archive;
|
using OpenSim.Framework.Archive;
|
||||||
using OpenSim.Framework.Servers;
|
using OpenSim.Framework.Servers;
|
||||||
using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
|
|
||||||
using log4net;
|
using log4net;
|
||||||
|
|
||||||
namespace OpenSim.Grid.AssetInventoryServer.Plugins
|
namespace OpenSim.Grid.AssetInventoryServer.Plugins
|
||||||
|
@ -146,7 +145,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins
|
||||||
MemoryStream ms = new MemoryStream();
|
MemoryStream ms = new MemoryStream();
|
||||||
GZipStream gzs = new GZipStream(ms, CompressionMode.Compress, true);
|
GZipStream gzs = new GZipStream(ms, CompressionMode.Compress, true);
|
||||||
TarArchiveWriter archive = new TarArchiveWriter(gzs);
|
TarArchiveWriter archive = new TarArchiveWriter(gzs);
|
||||||
WriteInventoryFolderToArchive(archive, rootFolder, InventoryArchiveConstants.INVENTORY_PATH);
|
WriteInventoryFolderToArchive(archive, rootFolder, ArchiveConstants.INVENTORY_PATH);
|
||||||
|
|
||||||
archive.Close();
|
archive.Close();
|
||||||
|
|
||||||
|
@ -181,7 +180,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins
|
||||||
|
|
||||||
private static void WriteInventoryFolderToArchive(TarArchiveWriter archive, InventoryFolderWithChildren folder, string path)
|
private static void WriteInventoryFolderToArchive(TarArchiveWriter archive, InventoryFolderWithChildren folder, string path)
|
||||||
{
|
{
|
||||||
path += string.Format("{0}{1}{2}/", folder.Name, InventoryArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, folder.ID);
|
path += string.Format("{0}{1}{2}/", folder.Name, ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, folder.ID);
|
||||||
archive.WriteDir(path);
|
archive.WriteDir(path);
|
||||||
|
|
||||||
foreach (InventoryNodeBase inventoryNode in folder.Children.Values)
|
foreach (InventoryNodeBase inventoryNode in folder.Children.Values)
|
||||||
|
|
|
@ -1,113 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSim Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using OpenMetaverse;
|
|
||||||
|
|
||||||
namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Constants for the inventory archiving module
|
|
||||||
/// </summary>
|
|
||||||
public class InventoryArchiveConstants
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Path for the inventory data
|
|
||||||
/// </summary>
|
|
||||||
public static readonly string INVENTORY_PATH = "inventory/";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Path for the assets held in an archive
|
|
||||||
/// </summary>
|
|
||||||
public static readonly string ASSETS_PATH = "assets/";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The character the separates the uuid from extension information in an archived asset filename
|
|
||||||
/// </summary>
|
|
||||||
public static readonly string ASSET_EXTENSION_SEPARATOR = "_";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Used to separate components in an inventory node name
|
|
||||||
/// </summary>
|
|
||||||
public static readonly string INVENTORY_NODE_NAME_COMPONENT_SEPARATOR = "__";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Extensions used for asset types in the archive
|
|
||||||
/// </summary>
|
|
||||||
public static readonly IDictionary<sbyte, string> ASSET_TYPE_TO_EXTENSION = new Dictionary<sbyte, string>();
|
|
||||||
public static readonly IDictionary<string, sbyte> EXTENSION_TO_ASSET_TYPE = new Dictionary<string, sbyte>();
|
|
||||||
|
|
||||||
static InventoryArchiveConstants()
|
|
||||||
{
|
|
||||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Animation] = ASSET_EXTENSION_SEPARATOR + "animation.bvh";
|
|
||||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Bodypart] = ASSET_EXTENSION_SEPARATOR + "bodypart.txt";
|
|
||||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.CallingCard] = ASSET_EXTENSION_SEPARATOR + "callingcard.txt";
|
|
||||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Clothing] = ASSET_EXTENSION_SEPARATOR + "clothing.txt";
|
|
||||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Folder] = ASSET_EXTENSION_SEPARATOR + "folder.txt"; // Not sure if we'll ever see this
|
|
||||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Gesture] = ASSET_EXTENSION_SEPARATOR + "gesture.txt";
|
|
||||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.ImageJPEG] = ASSET_EXTENSION_SEPARATOR + "image.jpg";
|
|
||||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.ImageTGA] = ASSET_EXTENSION_SEPARATOR + "image.tga";
|
|
||||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Landmark] = ASSET_EXTENSION_SEPARATOR + "landmark.txt";
|
|
||||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.LostAndFoundFolder] = ASSET_EXTENSION_SEPARATOR + "lostandfoundfolder.txt"; // Not sure if we'll ever see this
|
|
||||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.LSLBytecode] = ASSET_EXTENSION_SEPARATOR + "bytecode.lso";
|
|
||||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.LSLText] = ASSET_EXTENSION_SEPARATOR + "script.lsl";
|
|
||||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Notecard] = ASSET_EXTENSION_SEPARATOR + "notecard.txt";
|
|
||||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Object] = ASSET_EXTENSION_SEPARATOR + "object.xml";
|
|
||||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.RootFolder] = ASSET_EXTENSION_SEPARATOR + "rootfolder.txt"; // Not sure if we'll ever see this
|
|
||||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Simstate] = ASSET_EXTENSION_SEPARATOR + "simstate.bin"; // Not sure if we'll ever see this
|
|
||||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SnapshotFolder] = ASSET_EXTENSION_SEPARATOR + "snapshotfolder.txt"; // Not sure if we'll ever see this
|
|
||||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Sound] = ASSET_EXTENSION_SEPARATOR + "sound.ogg";
|
|
||||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SoundWAV] = ASSET_EXTENSION_SEPARATOR + "sound.wav";
|
|
||||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.Texture] = ASSET_EXTENSION_SEPARATOR + "texture.jp2";
|
|
||||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TextureTGA] = ASSET_EXTENSION_SEPARATOR + "texture.tga";
|
|
||||||
ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.TrashFolder] = ASSET_EXTENSION_SEPARATOR + "trashfolder.txt"; // Not sure if we'll ever see this
|
|
||||||
|
|
||||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "animation.bvh"] = (sbyte)AssetType.Animation;
|
|
||||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "bodypart.txt"] = (sbyte)AssetType.Bodypart;
|
|
||||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "callingcard.txt"] = (sbyte)AssetType.CallingCard;
|
|
||||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "clothing.txt"] = (sbyte)AssetType.Clothing;
|
|
||||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "folder.txt"] = (sbyte)AssetType.Folder;
|
|
||||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "gesture.txt"] = (sbyte)AssetType.Gesture;
|
|
||||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "image.jpg"] = (sbyte)AssetType.ImageJPEG;
|
|
||||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "image.tga"] = (sbyte)AssetType.ImageTGA;
|
|
||||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "landmark.txt"] = (sbyte)AssetType.Landmark;
|
|
||||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "lostandfoundfolder.txt"] = (sbyte)AssetType.LostAndFoundFolder;
|
|
||||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "bytecode.lso"] = (sbyte)AssetType.LSLBytecode;
|
|
||||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "script.lsl"] = (sbyte)AssetType.LSLText;
|
|
||||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "notecard.txt"] = (sbyte)AssetType.Notecard;
|
|
||||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "object.xml"] = (sbyte)AssetType.Object;
|
|
||||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "rootfolder.txt"] = (sbyte)AssetType.RootFolder;
|
|
||||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "simstate.bin"] = (sbyte)AssetType.Simstate;
|
|
||||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "snapshotfolder.txt"] = (sbyte)AssetType.SnapshotFolder;
|
|
||||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "sound.ogg"] = (sbyte)AssetType.Sound;
|
|
||||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "sound.wav"] = (sbyte)AssetType.SoundWAV;
|
|
||||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "texture.jp2"] = (sbyte)AssetType.Texture;
|
|
||||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "texture.tga"] = (sbyte)AssetType.TextureTGA;
|
|
||||||
EXTENSION_TO_ASSET_TYPE[ASSET_EXTENSION_SEPARATOR + "trashfolder.txt"] = (sbyte)AssetType.TrashFolder;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -51,32 +51,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
|
|
||||||
private CachedUserInfo m_userInfo;
|
private CachedUserInfo m_userInfo;
|
||||||
private string m_invPath;
|
private string m_invPath;
|
||||||
|
|
||||||
/// <value>
|
/// <value>
|
||||||
/// The stream from which the inventory archive will be loaded.
|
/// The stream from which the inventory archive will be loaded.
|
||||||
/// </value>
|
/// </value>
|
||||||
private Stream m_loadStream;
|
private Stream m_loadStream;
|
||||||
|
|
||||||
CommunicationsManager commsManager;
|
CommunicationsManager commsManager;
|
||||||
|
|
||||||
public InventoryArchiveReadRequest(
|
public InventoryArchiveReadRequest(
|
||||||
CachedUserInfo userInfo, string invPath, string loadPath, CommunicationsManager commsManager)
|
CachedUserInfo userInfo, string invPath, string loadPath, CommunicationsManager commsManager)
|
||||||
: this(
|
: this(
|
||||||
userInfo,
|
userInfo,
|
||||||
invPath,
|
invPath,
|
||||||
new GZipStream(new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress),
|
new GZipStream(new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress),
|
||||||
commsManager)
|
commsManager)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public InventoryArchiveReadRequest(
|
public InventoryArchiveReadRequest(
|
||||||
CachedUserInfo userInfo, string invPath, Stream loadStream, CommunicationsManager commsManager)
|
CachedUserInfo userInfo, string invPath, Stream loadStream, CommunicationsManager commsManager)
|
||||||
{
|
{
|
||||||
m_userInfo = userInfo;
|
m_userInfo = userInfo;
|
||||||
m_invPath = invPath;
|
m_invPath = invPath;
|
||||||
m_loadStream = loadStream;
|
m_loadStream = loadStream;
|
||||||
this.commsManager = commsManager;
|
this.commsManager = commsManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected InventoryItemBase LoadInvItem(string contents)
|
protected InventoryItemBase LoadInvItem(string contents)
|
||||||
{
|
{
|
||||||
|
@ -157,11 +157,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
int failedAssetRestores = 0;
|
int failedAssetRestores = 0;
|
||||||
int successfulItemRestores = 0;
|
int successfulItemRestores = 0;
|
||||||
List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>();
|
List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>();
|
||||||
|
|
||||||
if (!m_userInfo.HasReceivedInventory)
|
if (!m_userInfo.HasReceivedInventory)
|
||||||
{
|
{
|
||||||
// If the region server has access to the user admin service (by which users are created),
|
// If the region server has access to the user admin service (by which users are created),
|
||||||
// then we'll assume that it's okay to fiddle with the user's inventory even if they are not on the
|
// then we'll assume that it's okay to fiddle with the user's inventory even if they are not on the
|
||||||
// server.
|
// server.
|
||||||
//
|
//
|
||||||
// FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might
|
// FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might
|
||||||
|
@ -191,7 +191,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
}
|
}
|
||||||
|
|
||||||
archive = new TarArchiveReader(m_loadStream);
|
archive = new TarArchiveReader(m_loadStream);
|
||||||
|
|
||||||
// In order to load identically named folders, we need to keep track of the folders that we have already
|
// In order to load identically named folders, we need to keep track of the folders that we have already
|
||||||
// created
|
// created
|
||||||
Dictionary <string, InventoryFolderImpl> foldersCreated = new Dictionary<string, InventoryFolderImpl>();
|
Dictionary <string, InventoryFolderImpl> foldersCreated = new Dictionary<string, InventoryFolderImpl>();
|
||||||
|
@ -200,18 +200,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
TarArchiveReader.TarEntryType entryType;
|
TarArchiveReader.TarEntryType entryType;
|
||||||
while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
|
while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
|
||||||
{
|
{
|
||||||
if (entryType == TarArchiveReader.TarEntryType.TYPE_DIRECTORY)
|
if (entryType == TarArchiveReader.TarEntryType.TYPE_DIRECTORY)
|
||||||
{
|
{
|
||||||
m_log.WarnFormat("[INVENTORY ARCHIVER]: Ignoring directory entry {0}", filePath);
|
m_log.WarnFormat("[INVENTORY ARCHIVER]: Ignoring directory entry {0}", filePath);
|
||||||
}
|
}
|
||||||
else if (filePath.StartsWith(InventoryArchiveConstants.ASSETS_PATH))
|
else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
|
||||||
{
|
{
|
||||||
if (LoadAsset(filePath, data))
|
if (LoadAsset(filePath, data))
|
||||||
successfulAssetRestores++;
|
successfulAssetRestores++;
|
||||||
else
|
else
|
||||||
failedAssetRestores++;
|
failedAssetRestores++;
|
||||||
}
|
}
|
||||||
else if (filePath.StartsWith(InventoryArchiveConstants.INVENTORY_PATH))
|
else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH))
|
||||||
{
|
{
|
||||||
InventoryItemBase item = LoadInvItem(m_asciiEncoding.GetString(data));
|
InventoryItemBase item = LoadInvItem(m_asciiEncoding.GetString(data));
|
||||||
|
|
||||||
|
@ -219,16 +219,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
{
|
{
|
||||||
// Don't use the item ID that's in the file
|
// Don't use the item ID that's in the file
|
||||||
item.ID = UUID.Random();
|
item.ID = UUID.Random();
|
||||||
|
|
||||||
item.Creator = m_userInfo.UserProfile.ID;
|
item.Creator = m_userInfo.UserProfile.ID;
|
||||||
item.Owner = m_userInfo.UserProfile.ID;
|
item.Owner = m_userInfo.UserProfile.ID;
|
||||||
|
|
||||||
string fsPath = filePath.Substring(InventoryArchiveConstants.INVENTORY_PATH.Length);
|
string fsPath = filePath.Substring(ArchiveConstants.INVENTORY_PATH.Length);
|
||||||
fsPath = fsPath.Remove(fsPath.LastIndexOf("/") + 1);
|
fsPath = fsPath.Remove(fsPath.LastIndexOf("/") + 1);
|
||||||
string originalFsPath = fsPath;
|
string originalFsPath = fsPath;
|
||||||
|
|
||||||
m_log.DebugFormat("[INVENTORY ARCHIVER]: Loading to folder {0}", fsPath);
|
m_log.DebugFormat("[INVENTORY ARCHIVER]: Loading to folder {0}", fsPath);
|
||||||
|
|
||||||
InventoryFolderImpl foundFolder = null;
|
InventoryFolderImpl foundFolder = null;
|
||||||
while (null == foundFolder && fsPath.Length > 0)
|
while (null == foundFolder && fsPath.Length > 0)
|
||||||
{
|
{
|
||||||
|
@ -241,7 +241,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
{
|
{
|
||||||
// Don't include the last slash
|
// Don't include the last slash
|
||||||
int penultimateSlashIndex = fsPath.LastIndexOf("/", fsPath.Length - 2);
|
int penultimateSlashIndex = fsPath.LastIndexOf("/", fsPath.Length - 2);
|
||||||
|
|
||||||
if (penultimateSlashIndex >= 0)
|
if (penultimateSlashIndex >= 0)
|
||||||
{
|
{
|
||||||
fsPath = fsPath.Remove(penultimateSlashIndex + 1);
|
fsPath = fsPath.Remove(penultimateSlashIndex + 1);
|
||||||
|
@ -254,42 +254,42 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
fsPath = string.Empty;
|
fsPath = string.Empty;
|
||||||
foundFolder = rootDestinationFolder;
|
foundFolder = rootDestinationFolder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string fsPathSectionToCreate = originalFsPath.Substring(fsPath.Length);
|
string fsPathSectionToCreate = originalFsPath.Substring(fsPath.Length);
|
||||||
string[] rawDirsToCreate
|
string[] rawDirsToCreate
|
||||||
= fsPathSectionToCreate.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
|
= fsPathSectionToCreate.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while (i < rawDirsToCreate.Length)
|
while (i < rawDirsToCreate.Length)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawDirsToCreate[i]);
|
m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawDirsToCreate[i]);
|
||||||
|
|
||||||
int identicalNameIdentifierIndex
|
int identicalNameIdentifierIndex
|
||||||
= rawDirsToCreate[i].LastIndexOf(
|
= rawDirsToCreate[i].LastIndexOf(
|
||||||
InventoryArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR);
|
ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR);
|
||||||
string folderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex);
|
string folderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex);
|
||||||
|
|
||||||
UUID newFolderId = UUID.Random();
|
UUID newFolderId = UUID.Random();
|
||||||
m_userInfo.CreateFolder(
|
m_userInfo.CreateFolder(
|
||||||
folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID);
|
folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID);
|
||||||
foundFolder = foundFolder.GetChildFolder(newFolderId);
|
foundFolder = foundFolder.GetChildFolder(newFolderId);
|
||||||
|
|
||||||
// Record that we have now created this folder
|
// Record that we have now created this folder
|
||||||
fsPath += rawDirsToCreate[i] + "/";
|
fsPath += rawDirsToCreate[i] + "/";
|
||||||
m_log.DebugFormat("[INVENTORY ARCHIVER]: Recording creation of fs path {0}", fsPath);
|
m_log.DebugFormat("[INVENTORY ARCHIVER]: Recording creation of fs path {0}", fsPath);
|
||||||
foldersCreated[fsPath] = foundFolder;
|
foldersCreated[fsPath] = foundFolder;
|
||||||
|
|
||||||
if (0 == i)
|
if (0 == i)
|
||||||
nodesLoaded.Add(foundFolder);
|
nodesLoaded.Add(foundFolder);
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
string[] rawFolders = filePath.Split(new char[] { '/' });
|
string[] rawFolders = filePath.Split(new char[] { '/' });
|
||||||
|
|
||||||
// Find the folders that do exist along the path given
|
// Find the folders that do exist along the path given
|
||||||
int i = 0;
|
int i = 0;
|
||||||
bool noFolder = false;
|
bool noFolder = false;
|
||||||
|
@ -306,27 +306,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
noFolder = true;
|
noFolder = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create any folders that did not previously exist
|
// Create any folders that did not previously exist
|
||||||
while (i < rawFolders.Length)
|
while (i < rawFolders.Length)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawFolders[i]);
|
m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawFolders[i]);
|
||||||
|
|
||||||
UUID newFolderId = UUID.Random();
|
UUID newFolderId = UUID.Random();
|
||||||
m_userInfo.CreateFolder(
|
m_userInfo.CreateFolder(
|
||||||
rawFolders[i++], newFolderId, (ushort)AssetType.Folder, foundFolder.ID);
|
rawFolders[i++], newFolderId, (ushort)AssetType.Folder, foundFolder.ID);
|
||||||
foundFolder = foundFolder.GetChildFolder(newFolderId);
|
foundFolder = foundFolder.GetChildFolder(newFolderId);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Reset folder ID to the one in which we want to load it
|
// Reset folder ID to the one in which we want to load it
|
||||||
item.Folder = foundFolder.ID;
|
item.Folder = foundFolder.ID;
|
||||||
|
|
||||||
m_userInfo.AddItem(item);
|
m_userInfo.AddItem(item);
|
||||||
successfulItemRestores++;
|
successfulItemRestores++;
|
||||||
|
|
||||||
// If we're loading an item directly into the given destination folder then we need to record
|
// If we're loading an item directly into the given destination folder then we need to record
|
||||||
// it separately from any loaded root folders
|
// it separately from any loaded root folders
|
||||||
if (rootDestinationFolder == foundFolder)
|
if (rootDestinationFolder == foundFolder)
|
||||||
|
@ -339,7 +339,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
|
|
||||||
m_log.DebugFormat("[INVENTORY ARCHIVER]: Restored {0} assets", successfulAssetRestores);
|
m_log.DebugFormat("[INVENTORY ARCHIVER]: Restored {0} assets", successfulAssetRestores);
|
||||||
m_log.InfoFormat("[INVENTORY ARCHIVER]: Restored {0} items", successfulItemRestores);
|
m_log.InfoFormat("[INVENTORY ARCHIVER]: Restored {0} items", successfulItemRestores);
|
||||||
|
|
||||||
return nodesLoaded;
|
return nodesLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,14 +353,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
{
|
{
|
||||||
//IRegionSerialiser serialiser = scene.RequestModuleInterface<IRegionSerialiser>();
|
//IRegionSerialiser serialiser = scene.RequestModuleInterface<IRegionSerialiser>();
|
||||||
// Right now we're nastily obtaining the UUID from the filename
|
// Right now we're nastily obtaining the UUID from the filename
|
||||||
string filename = assetPath.Remove(0, InventoryArchiveConstants.ASSETS_PATH.Length);
|
string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length);
|
||||||
int i = filename.LastIndexOf(InventoryArchiveConstants.ASSET_EXTENSION_SEPARATOR);
|
int i = filename.LastIndexOf(ArchiveConstants.ASSET_EXTENSION_SEPARATOR);
|
||||||
|
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
{
|
{
|
||||||
m_log.ErrorFormat(
|
m_log.ErrorFormat(
|
||||||
"[INVENTORY ARCHIVER]: Could not find extension information in asset path {0} since it's missing the separator {1}. Skipping",
|
"[INVENTORY ARCHIVER]: Could not find extension information in asset path {0} since it's missing the separator {1}. Skipping",
|
||||||
assetPath, InventoryArchiveConstants.ASSET_EXTENSION_SEPARATOR);
|
assetPath, ArchiveConstants.ASSET_EXTENSION_SEPARATOR);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -368,9 +368,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
string extension = filename.Substring(i);
|
string extension = filename.Substring(i);
|
||||||
string uuid = filename.Remove(filename.Length - extension.Length);
|
string uuid = filename.Remove(filename.Length - extension.Length);
|
||||||
|
|
||||||
if (InventoryArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension))
|
if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension))
|
||||||
{
|
{
|
||||||
sbyte assetType = InventoryArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];
|
sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];
|
||||||
|
|
||||||
//m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType);
|
//m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType);
|
||||||
|
|
||||||
|
|
|
@ -41,47 +41,47 @@ using OpenSim.Region.CoreModules.World.Archiver;
|
||||||
using OpenSim.Region.Framework.Scenes;
|
using OpenSim.Region.Framework.Scenes;
|
||||||
|
|
||||||
namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
{
|
{
|
||||||
public class InventoryArchiveWriteRequest
|
public class InventoryArchiveWriteRequest
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
protected TarArchiveWriter m_archive;
|
protected TarArchiveWriter m_archive;
|
||||||
protected UuidGatherer m_assetGatherer;
|
protected UuidGatherer m_assetGatherer;
|
||||||
protected Dictionary<UUID, int> assetUuids = new Dictionary<UUID, int>();
|
protected Dictionary<UUID, int> assetUuids = new Dictionary<UUID, int>();
|
||||||
|
|
||||||
private InventoryArchiverModule m_module;
|
private InventoryArchiverModule m_module;
|
||||||
private CachedUserInfo m_userInfo;
|
private CachedUserInfo m_userInfo;
|
||||||
private string m_invPath;
|
private string m_invPath;
|
||||||
|
|
||||||
/// <value>
|
/// <value>
|
||||||
/// The stream to which the inventory archive will be saved.
|
/// The stream to which the inventory archive will be saved.
|
||||||
/// </value>
|
/// </value>
|
||||||
private Stream m_saveStream;
|
private Stream m_saveStream;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public InventoryArchiveWriteRequest(
|
public InventoryArchiveWriteRequest(
|
||||||
InventoryArchiverModule module, CachedUserInfo userInfo, string invPath, string savePath)
|
InventoryArchiverModule module, CachedUserInfo userInfo, string invPath, string savePath)
|
||||||
: this(
|
: this(
|
||||||
module,
|
module,
|
||||||
userInfo,
|
userInfo,
|
||||||
invPath,
|
invPath,
|
||||||
new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress))
|
new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public InventoryArchiveWriteRequest(
|
public InventoryArchiveWriteRequest(
|
||||||
InventoryArchiverModule module, CachedUserInfo userInfo, string invPath, Stream saveStream)
|
InventoryArchiverModule module, CachedUserInfo userInfo, string invPath, Stream saveStream)
|
||||||
{
|
{
|
||||||
m_module = module;
|
m_module = module;
|
||||||
m_userInfo = userInfo;
|
m_userInfo = userInfo;
|
||||||
m_invPath = invPath;
|
m_invPath = invPath;
|
||||||
m_saveStream = saveStream;
|
m_saveStream = saveStream;
|
||||||
m_assetGatherer = new UuidGatherer(m_module.CommsManager.AssetCache);
|
m_assetGatherer = new UuidGatherer(m_module.CommsManager.AssetCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,22 +89,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
{
|
{
|
||||||
AssetsArchiver assetsArchiver = new AssetsArchiver(assetsFound);
|
AssetsArchiver assetsArchiver = new AssetsArchiver(assetsFound);
|
||||||
assetsArchiver.Archive(m_archive);
|
assetsArchiver.Archive(m_archive);
|
||||||
|
|
||||||
Exception reportedException = null;
|
Exception reportedException = null;
|
||||||
bool succeeded = true;
|
bool succeeded = true;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_archive.Close();
|
m_archive.Close();
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
m_saveStream.Close();
|
m_saveStream.Close();
|
||||||
reportedException = e;
|
reportedException = e;
|
||||||
succeeded = false;
|
succeeded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_module.TriggerInventoryArchiveSaved(succeeded, m_userInfo, m_invPath, m_saveStream, reportedException);
|
m_module.TriggerInventoryArchiveSaved(succeeded, m_userInfo, m_invPath, m_saveStream, reportedException);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void SaveInvItem(InventoryItemBase inventoryItem, string path)
|
protected void SaveInvItem(InventoryItemBase inventoryItem, string path)
|
||||||
|
@ -113,9 +113,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
XmlTextWriter writer = new XmlTextWriter(sw);
|
XmlTextWriter writer = new XmlTextWriter(sw);
|
||||||
writer.Formatting = Formatting.Indented;
|
writer.Formatting = Formatting.Indented;
|
||||||
|
|
||||||
writer.WriteStartElement("InventoryItem");
|
writer.WriteStartElement("InventoryItem");
|
||||||
|
|
||||||
writer.WriteStartElement("Name");
|
writer.WriteStartElement("Name");
|
||||||
writer.WriteString(inventoryItem.Name);
|
writer.WriteString(inventoryItem.Name);
|
||||||
writer.WriteEndElement();
|
writer.WriteEndElement();
|
||||||
|
@ -170,7 +170,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
writer.WriteStartElement("GroupOwned");
|
writer.WriteStartElement("GroupOwned");
|
||||||
writer.WriteString(inventoryItem.GroupOwned.ToString());
|
writer.WriteString(inventoryItem.GroupOwned.ToString());
|
||||||
writer.WriteEndElement();
|
writer.WriteEndElement();
|
||||||
|
|
||||||
writer.WriteEndElement();
|
writer.WriteEndElement();
|
||||||
|
|
||||||
m_archive.WriteFile(filename, sw.ToString());
|
m_archive.WriteFile(filename, sw.ToString());
|
||||||
|
@ -180,43 +180,43 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
|
|
||||||
protected void SaveInvDir(InventoryFolderImpl inventoryFolder, string path)
|
protected void SaveInvDir(InventoryFolderImpl inventoryFolder, string path)
|
||||||
{
|
{
|
||||||
path +=
|
path +=
|
||||||
string.Format(
|
string.Format(
|
||||||
"{0}{1}{2}/",
|
"{0}{1}{2}/",
|
||||||
inventoryFolder.Name,
|
inventoryFolder.Name,
|
||||||
InventoryArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR,
|
ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR,
|
||||||
inventoryFolder.ID);
|
inventoryFolder.ID);
|
||||||
m_archive.WriteDir(path);
|
m_archive.WriteDir(path);
|
||||||
|
|
||||||
List<InventoryFolderImpl> childFolders = inventoryFolder.RequestListOfFolderImpls();
|
List<InventoryFolderImpl> childFolders = inventoryFolder.RequestListOfFolderImpls();
|
||||||
List<InventoryItemBase> items = inventoryFolder.RequestListOfItems();
|
List<InventoryItemBase> items = inventoryFolder.RequestListOfItems();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Dictionary identicalFolderNames = new Dictionary<string, int>();
|
Dictionary identicalFolderNames = new Dictionary<string, int>();
|
||||||
|
|
||||||
foreach (InventoryFolderImpl folder in inventories)
|
foreach (InventoryFolderImpl folder in inventories)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!identicalFolderNames.ContainsKey(folder.Name))
|
if (!identicalFolderNames.ContainsKey(folder.Name))
|
||||||
identicalFolderNames[folder.Name] = 0;
|
identicalFolderNames[folder.Name] = 0;
|
||||||
else
|
else
|
||||||
identicalFolderNames[folder.Name] = identicalFolderNames[folder.Name]++;
|
identicalFolderNames[folder.Name] = identicalFolderNames[folder.Name]++;
|
||||||
|
|
||||||
int folderNameNumber = identicalFolderName[folder.Name];
|
int folderNameNumber = identicalFolderName[folder.Name];
|
||||||
|
|
||||||
SaveInvDir(
|
SaveInvDir(
|
||||||
folder,
|
folder,
|
||||||
string.Format(
|
string.Format(
|
||||||
"{0}{1}{2}/",
|
"{0}{1}{2}/",
|
||||||
path, InventoryArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, folderNameNumber));
|
path, ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, folderNameNumber));
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
foreach (InventoryFolderImpl childFolder in childFolders)
|
foreach (InventoryFolderImpl childFolder in childFolders)
|
||||||
{
|
{
|
||||||
SaveInvDir(childFolder, path);
|
SaveInvDir(childFolder, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (InventoryItemBase item in items)
|
foreach (InventoryItemBase item in items)
|
||||||
{
|
{
|
||||||
SaveInvItem(item, path);
|
SaveInvItem(item, path);
|
||||||
|
@ -232,9 +232,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
InventoryItemBase inventoryItem = null;
|
InventoryItemBase inventoryItem = null;
|
||||||
|
|
||||||
if (!m_userInfo.HasReceivedInventory)
|
if (!m_userInfo.HasReceivedInventory)
|
||||||
{
|
{
|
||||||
// If the region server has access to the user admin service (by which users are created),
|
// If the region server has access to the user admin service (by which users are created),
|
||||||
// then we'll assume that it's okay to fiddle with the user's inventory even if they are not on the
|
// then we'll assume that it's okay to fiddle with the user's inventory even if they are not on the
|
||||||
// server.
|
// server.
|
||||||
//
|
//
|
||||||
// FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might
|
// FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might
|
||||||
|
@ -252,7 +252,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
m_userInfo.FetchInventory();
|
m_userInfo.FetchInventory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Eliminate double slashes and any leading / on the path. This might be better done within InventoryFolderImpl
|
// Eliminate double slashes and any leading / on the path. This might be better done within InventoryFolderImpl
|
||||||
// itself (possibly at a small loss in efficiency).
|
// itself (possibly at a small loss in efficiency).
|
||||||
string[] components
|
string[] components
|
||||||
|
@ -280,8 +280,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
{
|
{
|
||||||
inventoryItem = m_userInfo.RootFolder.FindItemByPath(m_invPath);
|
inventoryItem = m_userInfo.RootFolder.FindItemByPath(m_invPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_archive = new TarArchiveWriter(m_saveStream);
|
m_archive = new TarArchiveWriter(m_saveStream);
|
||||||
|
|
||||||
if (null == inventoryFolder)
|
if (null == inventoryFolder)
|
||||||
{
|
{
|
||||||
|
@ -289,16 +289,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
{
|
{
|
||||||
m_saveStream.Close();
|
m_saveStream.Close();
|
||||||
m_module.TriggerInventoryArchiveSaved(
|
m_module.TriggerInventoryArchiveSaved(
|
||||||
false, m_userInfo, m_invPath, m_saveStream,
|
false, m_userInfo, m_invPath, m_saveStream,
|
||||||
new Exception(string.Format("Could not find inventory entry at path {0}", m_invPath)));
|
new Exception(string.Format("Could not find inventory entry at path {0}", m_invPath)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_log.DebugFormat(
|
m_log.DebugFormat(
|
||||||
"[INVENTORY ARCHIVER]: Found item {0} {1} at {2}",
|
"[INVENTORY ARCHIVER]: Found item {0} {1} at {2}",
|
||||||
inventoryItem.Name, inventoryItem.ID, m_invPath);
|
inventoryItem.Name, inventoryItem.ID, m_invPath);
|
||||||
|
|
||||||
//get and export item info
|
//get and export item info
|
||||||
SaveInvItem(inventoryItem, m_invPath);
|
SaveInvItem(inventoryItem, m_invPath);
|
||||||
}
|
}
|
||||||
|
@ -306,11 +306,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_log.DebugFormat(
|
m_log.DebugFormat(
|
||||||
"[INVENTORY ARCHIVER]: Found folder {0} {1} at {2}",
|
"[INVENTORY ARCHIVER]: Found folder {0} {1} at {2}",
|
||||||
inventoryFolder.Name, inventoryFolder.ID, m_invPath);
|
inventoryFolder.Name, inventoryFolder.ID, m_invPath);
|
||||||
|
|
||||||
//recurse through all dirs getting dirs and files
|
//recurse through all dirs getting dirs and files
|
||||||
SaveInvDir(inventoryFolder, InventoryArchiveConstants.INVENTORY_PATH);
|
SaveInvDir(inventoryFolder, ArchiveConstants.INVENTORY_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
new AssetsRequest(assetUuids.Keys, m_module.CommsManager.AssetCache, ReceivedAllAssets).Execute();
|
new AssetsRequest(assetUuids.Keys, m_module.CommsManager.AssetCache, ReceivedAllAssets).Execute();
|
||||||
|
|
|
@ -53,31 +53,31 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
lock (this)
|
lock (this)
|
||||||
{
|
{
|
||||||
Monitor.PulseAll(this);
|
Monitor.PulseAll(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Test saving a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet).
|
/// Test saving a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Test]
|
[Test]
|
||||||
public void TestSaveIarV0p1()
|
public void TestSaveIarV0p1()
|
||||||
{
|
{
|
||||||
//log4net.Config.XmlConfigurator.Configure();
|
//log4net.Config.XmlConfigurator.Configure();
|
||||||
|
|
||||||
InventoryArchiverModule archiverModule = new InventoryArchiverModule();
|
InventoryArchiverModule archiverModule = new InventoryArchiverModule();
|
||||||
|
|
||||||
Scene scene = SceneSetupHelpers.SetupScene();
|
Scene scene = SceneSetupHelpers.SetupScene();
|
||||||
SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
|
SceneSetupHelpers.SetupSceneModules(scene, archiverModule);
|
||||||
CommunicationsManager cm = scene.CommsManager;
|
CommunicationsManager cm = scene.CommsManager;
|
||||||
|
|
||||||
// Create user
|
// Create user
|
||||||
string userFirstName = "Jock";
|
string userFirstName = "Jock";
|
||||||
string userLastName = "Stirrup";
|
string userLastName = "Stirrup";
|
||||||
UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
|
UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
|
||||||
cm.UserAdminService.AddUser(userFirstName, userLastName, string.Empty, string.Empty, 1000, 1000, userId);
|
cm.UserAdminService.AddUser(userFirstName, userLastName, string.Empty, string.Empty, 1000, 1000, userId);
|
||||||
CachedUserInfo userInfo = cm.UserProfileCacheService.GetUserDetails(userId);
|
CachedUserInfo userInfo = cm.UserProfileCacheService.GetUserDetails(userId);
|
||||||
userInfo.FetchInventory();
|
userInfo.FetchInventory();
|
||||||
|
|
||||||
// Create asset
|
// Create asset
|
||||||
SceneObjectGroup object1;
|
SceneObjectGroup object1;
|
||||||
SceneObjectPart part1;
|
SceneObjectPart part1;
|
||||||
|
@ -88,81 +88,81 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
Vector3 groupPosition = new Vector3(10, 20, 30);
|
Vector3 groupPosition = new Vector3(10, 20, 30);
|
||||||
Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
|
Quaternion rotationOffset = new Quaternion(20, 30, 40, 50);
|
||||||
Vector3 offsetPosition = new Vector3(5, 10, 15);
|
Vector3 offsetPosition = new Vector3(5, 10, 15);
|
||||||
|
|
||||||
part1
|
part1
|
||||||
= new SceneObjectPart(
|
= new SceneObjectPart(
|
||||||
ownerId, shape, groupPosition, rotationOffset, offsetPosition);
|
ownerId, shape, groupPosition, rotationOffset, offsetPosition);
|
||||||
part1.Name = partName;
|
part1.Name = partName;
|
||||||
|
|
||||||
object1 = new SceneObjectGroup(part1);
|
object1 = new SceneObjectGroup(part1);
|
||||||
}
|
}
|
||||||
|
|
||||||
UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
|
UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
|
||||||
AssetBase asset1 = new AssetBase();
|
AssetBase asset1 = new AssetBase();
|
||||||
asset1.FullID = asset1Id;
|
asset1.FullID = asset1Id;
|
||||||
asset1.Data = Encoding.ASCII.GetBytes(object1.ToXmlString2());
|
asset1.Data = Encoding.ASCII.GetBytes(object1.ToXmlString2());
|
||||||
cm.AssetCache.AddAsset(asset1);
|
cm.AssetCache.AddAsset(asset1);
|
||||||
|
|
||||||
// Create item
|
// Create item
|
||||||
UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
|
UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080");
|
||||||
InventoryItemBase item1 = new InventoryItemBase();
|
InventoryItemBase item1 = new InventoryItemBase();
|
||||||
item1.Name = "My Little Dog";
|
item1.Name = "My Little Dog";
|
||||||
item1.AssetID = asset1.FullID;
|
item1.AssetID = asset1.FullID;
|
||||||
item1.ID = item1Id;
|
item1.ID = item1Id;
|
||||||
item1.Folder = userInfo.RootFolder.FindFolderByPath("Objects").ID;
|
item1.Folder = userInfo.RootFolder.FindFolderByPath("Objects").ID;
|
||||||
scene.AddInventoryItem(userId, item1);
|
scene.AddInventoryItem(userId, item1);
|
||||||
|
|
||||||
MemoryStream archiveWriteStream = new MemoryStream();
|
MemoryStream archiveWriteStream = new MemoryStream();
|
||||||
archiverModule.OnInventoryArchiveSaved += SaveCompleted;
|
archiverModule.OnInventoryArchiveSaved += SaveCompleted;
|
||||||
|
|
||||||
lock (this)
|
lock (this)
|
||||||
{
|
{
|
||||||
archiverModule.ArchiveInventory(userFirstName, userLastName, "Objects", archiveWriteStream);
|
archiverModule.ArchiveInventory(userFirstName, userLastName, "Objects", archiveWriteStream);
|
||||||
Monitor.Wait(this, 60000);
|
Monitor.Wait(this, 60000);
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] archive = archiveWriteStream.ToArray();
|
byte[] archive = archiveWriteStream.ToArray();
|
||||||
MemoryStream archiveReadStream = new MemoryStream(archive);
|
MemoryStream archiveReadStream = new MemoryStream(archive);
|
||||||
TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
|
TarArchiveReader tar = new TarArchiveReader(archiveReadStream);
|
||||||
|
|
||||||
InventoryFolderImpl objectsFolder = userInfo.RootFolder.FindFolderByPath("Objects");
|
InventoryFolderImpl objectsFolder = userInfo.RootFolder.FindFolderByPath("Objects");
|
||||||
|
|
||||||
//bool gotControlFile = false;
|
//bool gotControlFile = false;
|
||||||
bool gotObject1File = false;
|
bool gotObject1File = false;
|
||||||
//bool gotObject2File = false;
|
//bool gotObject2File = false;
|
||||||
string expectedObject1FilePath = string.Format(
|
string expectedObject1FilePath = string.Format(
|
||||||
"{0}{1}/{2}_{3}.xml",
|
"{0}{1}/{2}_{3}.xml",
|
||||||
InventoryArchiveConstants.INVENTORY_PATH,
|
ArchiveConstants.INVENTORY_PATH,
|
||||||
string.Format(
|
string.Format(
|
||||||
"Objects{0}{1}", InventoryArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, objectsFolder.ID),
|
"Objects{0}{1}", ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, objectsFolder.ID),
|
||||||
item1.Name,
|
item1.Name,
|
||||||
item1Id);
|
item1Id);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
string expectedObject2FileName = string.Format(
|
string expectedObject2FileName = string.Format(
|
||||||
"{0}_{1:000}-{2:000}-{3:000}__{4}.xml",
|
"{0}_{1:000}-{2:000}-{3:000}__{4}.xml",
|
||||||
part2.Name,
|
part2.Name,
|
||||||
Math.Round(part2.GroupPosition.X), Math.Round(part2.GroupPosition.Y), Math.Round(part2.GroupPosition.Z),
|
Math.Round(part2.GroupPosition.X), Math.Round(part2.GroupPosition.Y), Math.Round(part2.GroupPosition.Z),
|
||||||
part2.UUID);
|
part2.UUID);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
string filePath;
|
string filePath;
|
||||||
TarArchiveReader.TarEntryType tarEntryType;
|
TarArchiveReader.TarEntryType tarEntryType;
|
||||||
|
|
||||||
while (tar.ReadEntry(out filePath, out tarEntryType) != null)
|
while (tar.ReadEntry(out filePath, out tarEntryType) != null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Got {0}", filePath);
|
Console.WriteLine("Got {0}", filePath);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (ArchiveConstants.CONTROL_FILE_PATH == filePath)
|
if (ArchiveConstants.CONTROL_FILE_PATH == filePath)
|
||||||
{
|
{
|
||||||
gotControlFile = true;
|
gotControlFile = true;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (filePath.StartsWith(InventoryArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml"))
|
if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH) && filePath.EndsWith(".xml"))
|
||||||
{
|
{
|
||||||
//string fileName = filePath.Remove(0, "Objects/".Length);
|
//string fileName = filePath.Remove(0, "Objects/".Length);
|
||||||
|
|
||||||
//if (fileName.StartsWith(part1.Name))
|
//if (fileName.StartsWith(part1.Name))
|
||||||
//{
|
//{
|
||||||
Assert.That(filePath, Is.EqualTo(expectedObject1FilePath));
|
Assert.That(filePath, Is.EqualTo(expectedObject1FilePath));
|
||||||
|
@ -171,7 +171,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
//else if (fileName.StartsWith(part2.Name))
|
//else if (fileName.StartsWith(part2.Name))
|
||||||
//{
|
//{
|
||||||
// Assert.That(fileName, Is.EqualTo(expectedObject2FileName));
|
// Assert.That(fileName, Is.EqualTo(expectedObject2FileName));
|
||||||
// gotObject2File = true;
|
// gotObject2File = true;
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,8 +179,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
|
||||||
//Assert.That(gotControlFile, Is.True, "No control file in archive");
|
//Assert.That(gotControlFile, Is.True, "No control file in archive");
|
||||||
Assert.That(gotObject1File, Is.True, "No item1 file in archive");
|
Assert.That(gotObject1File, Is.True, "No item1 file in archive");
|
||||||
//Assert.That(gotObject2File, Is.True, "No object2 file in archive");
|
//Assert.That(gotObject2File, Is.True, "No object2 file in archive");
|
||||||
|
|
||||||
// TODO: Test presence of more files and contents of files.
|
// TODO: Test presence of more files and contents of files.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ using System.Xml;
|
||||||
using log4net;
|
using log4net;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
using OpenSim.Framework.Archive;
|
||||||
|
|
||||||
namespace OpenSim.Region.CoreModules.World.Archiver
|
namespace OpenSim.Region.CoreModules.World.Archiver
|
||||||
{
|
{
|
||||||
|
|
64
prebuild.xml
64
prebuild.xml
|
@ -118,6 +118,7 @@
|
||||||
</Configuration>
|
</Configuration>
|
||||||
|
|
||||||
<ReferencePath>../../../bin/</ReferencePath>
|
<ReferencePath>../../../bin/</ReferencePath>
|
||||||
|
<Reference name="OpenMetaverse" />
|
||||||
<Reference name="System"/>
|
<Reference name="System"/>
|
||||||
<Reference name="log4net.dll"/>
|
<Reference name="log4net.dll"/>
|
||||||
|
|
||||||
|
@ -865,6 +866,36 @@
|
||||||
</Files>
|
</Files>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
||||||
|
<Project name="OpenSim.Grid.AssetInventoryServer.Plugins" path="OpenSim/Grid/AssetInventoryServer/Plugins" type="Library">
|
||||||
|
<Configuration name="Debug">
|
||||||
|
<Options>
|
||||||
|
<OutputPath>../../../../bin/</OutputPath>
|
||||||
|
</Options>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration name="Release">
|
||||||
|
<Options>
|
||||||
|
<OutputPath>../../../../bin/</OutputPath>
|
||||||
|
</Options>
|
||||||
|
</Configuration>
|
||||||
|
|
||||||
|
<ReferencePath>../../../../bin/</ReferencePath>
|
||||||
|
<Reference name="System"/>
|
||||||
|
<Reference name="System.Xml"/>
|
||||||
|
<Reference name="System.Web"/>
|
||||||
|
<Reference name="OpenMetaverseTypes"/>
|
||||||
|
<Reference name="OpenMetaverse.StructuredData"/>
|
||||||
|
<Reference name="OpenSim.Framework"/>
|
||||||
|
<Reference name="OpenSim.Framework.Archive"/>
|
||||||
|
<Reference name="OpenSim.Framework.Servers"/>
|
||||||
|
<Reference name="OpenSim.Grid.AssetInventoryServer" />
|
||||||
|
<Reference name="log4net"/>
|
||||||
|
|
||||||
|
<Files>
|
||||||
|
<Match pattern="*.cs" recurse="false" />
|
||||||
|
<Match path="Resources" pattern="*.addin.xml" buildAction="EmbeddedResource" recurse="true" />
|
||||||
|
</Files>
|
||||||
|
</Project>
|
||||||
|
|
||||||
<Project name="OpenSim.Grid.AssetInventoryServer.Plugins.Simple" path="OpenSim/Grid/AssetInventoryServer/Plugins/Simple" type="Library">
|
<Project name="OpenSim.Grid.AssetInventoryServer.Plugins.Simple" path="OpenSim/Grid/AssetInventoryServer/Plugins/Simple" type="Library">
|
||||||
<Configuration name="Debug">
|
<Configuration name="Debug">
|
||||||
<Options>
|
<Options>
|
||||||
|
@ -1141,39 +1172,6 @@
|
||||||
</Files>
|
</Files>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
||||||
<Project name="OpenSim.Grid.AssetInventoryServer.Plugins" path="OpenSim/Grid/AssetInventoryServer/Plugins" type="Library">
|
|
||||||
<Configuration name="Debug">
|
|
||||||
<Options>
|
|
||||||
<OutputPath>../../../../bin/</OutputPath>
|
|
||||||
</Options>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration name="Release">
|
|
||||||
<Options>
|
|
||||||
<OutputPath>../../../../bin/</OutputPath>
|
|
||||||
</Options>
|
|
||||||
</Configuration>
|
|
||||||
|
|
||||||
<ReferencePath>../../../../bin/</ReferencePath>
|
|
||||||
<Reference name="System"/>
|
|
||||||
<Reference name="System.Xml"/>
|
|
||||||
<Reference name="System.Web"/>
|
|
||||||
<Reference name="OpenMetaverseTypes"/>
|
|
||||||
<Reference name="OpenMetaverse.StructuredData"/>
|
|
||||||
<Reference name="OpenSim.Framework"/>
|
|
||||||
<Reference name="OpenSim.Framework.Archive"/>
|
|
||||||
<Reference name="OpenSim.Framework.Servers"/>
|
|
||||||
<Reference name="OpenSim.Grid.AssetInventoryServer" />
|
|
||||||
<Reference name="log4net"/>
|
|
||||||
|
|
||||||
<!-- Needed for InventoryArchiveConstants. Hopefully it can be moved to Framework or something so we don't depend on Region DLLs. -->
|
|
||||||
<Reference name="OpenSim.Region.CoreModules"/>
|
|
||||||
|
|
||||||
<Files>
|
|
||||||
<Match pattern="*.cs" recurse="false" />
|
|
||||||
<Match path="Resources" pattern="*.addin.xml" buildAction="EmbeddedResource" recurse="true" />
|
|
||||||
</Files>
|
|
||||||
</Project>
|
|
||||||
|
|
||||||
<Project name="OpenSim.Region.CoreModules.World.Terrain.DefaultEffects" path="OpenSim/Region/CoreModules/World/Terrain/DefaultEffects" type="Library">
|
<Project name="OpenSim.Region.CoreModules.World.Terrain.DefaultEffects" path="OpenSim/Region/CoreModules/World/Terrain/DefaultEffects" type="Library">
|
||||||
<Configuration name="Debug">
|
<Configuration name="Debug">
|
||||||
<Options>
|
<Options>
|
||||||
|
|
Loading…
Reference in New Issue