2008-09-29 14:55:26 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
2009-06-01 06:37:14 +00:00
|
|
|
* * Neither the name of the OpenSimulator Project nor the
|
2008-09-29 14:55:26 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2009-02-12 18:59:45 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.IO;
|
|
|
|
using System.IO.Compression;
|
|
|
|
using System.Reflection;
|
2009-06-11 20:50:23 +00:00
|
|
|
using System.Threading;
|
2009-02-12 18:59:45 +00:00
|
|
|
using System.Text;
|
|
|
|
using System.Xml;
|
|
|
|
using log4net;
|
|
|
|
using OpenMetaverse;
|
|
|
|
using OpenSim.Framework;
|
|
|
|
using OpenSim.Framework.Communications;
|
|
|
|
using OpenSim.Framework.Communications.Cache;
|
2009-05-04 17:32:20 +00:00
|
|
|
using OpenSim.Framework.Communications.Osp;
|
|
|
|
using OpenSim.Framework.Serialization;
|
|
|
|
using OpenSim.Framework.Serialization.External;
|
2009-02-12 18:59:45 +00:00
|
|
|
using OpenSim.Region.CoreModules.World.Archiver;
|
2009-09-06 19:16:56 +00:00
|
|
|
using OpenSim.Region.Framework.Scenes;
|
2009-05-15 05:00:25 +00:00
|
|
|
using OpenSim.Services.Interfaces;
|
2009-02-12 18:59:45 +00:00
|
|
|
|
2009-02-10 13:10:57 +00:00
|
|
|
namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
|
2008-09-29 14:55:26 +00:00
|
|
|
{
|
|
|
|
public class InventoryArchiveReadRequest
|
|
|
|
{
|
2008-12-03 05:18:28 +00:00
|
|
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
2009-02-04 00:01:36 +00:00
|
|
|
|
2008-09-29 14:55:26 +00:00
|
|
|
protected TarArchiveReader archive;
|
2008-10-19 18:19:18 +00:00
|
|
|
|
2009-02-12 17:41:09 +00:00
|
|
|
private CachedUserInfo m_userInfo;
|
2009-02-11 18:46:51 +00:00
|
|
|
private string m_invPath;
|
2009-03-12 06:04:17 +00:00
|
|
|
|
2009-09-06 19:16:56 +00:00
|
|
|
/// <value>
|
|
|
|
/// We only use this to request modules
|
|
|
|
/// </value>
|
|
|
|
protected Scene m_scene;
|
|
|
|
|
2009-02-11 18:46:51 +00:00
|
|
|
/// <value>
|
|
|
|
/// The stream from which the inventory archive will be loaded.
|
|
|
|
/// </value>
|
|
|
|
private Stream m_loadStream;
|
2009-03-12 06:04:17 +00:00
|
|
|
|
2009-02-11 18:46:51 +00:00
|
|
|
public InventoryArchiveReadRequest(
|
2009-09-06 19:16:56 +00:00
|
|
|
Scene scene, CachedUserInfo userInfo, string invPath, string loadPath)
|
2009-02-11 18:46:51 +00:00
|
|
|
: this(
|
2009-09-06 19:16:56 +00:00
|
|
|
scene,
|
2009-02-12 17:41:09 +00:00
|
|
|
userInfo,
|
2009-03-12 06:04:17 +00:00
|
|
|
invPath,
|
2009-09-06 19:16:56 +00:00
|
|
|
new GZipStream(new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress))
|
2008-09-29 14:55:26 +00:00
|
|
|
{
|
|
|
|
}
|
2009-03-12 06:04:17 +00:00
|
|
|
|
2009-02-11 18:46:51 +00:00
|
|
|
public InventoryArchiveReadRequest(
|
2009-09-06 19:16:56 +00:00
|
|
|
Scene scene, CachedUserInfo userInfo, string invPath, Stream loadStream)
|
2009-02-11 18:46:51 +00:00
|
|
|
{
|
2009-09-06 19:16:56 +00:00
|
|
|
m_scene = scene;
|
2009-02-12 17:41:09 +00:00
|
|
|
m_userInfo = userInfo;
|
2009-02-11 18:46:51 +00:00
|
|
|
m_invPath = invPath;
|
2009-03-12 06:04:17 +00:00
|
|
|
m_loadStream = loadStream;
|
|
|
|
}
|
2008-09-29 14:55:26 +00:00
|
|
|
|
2009-02-11 20:24:41 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Execute the request
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>
|
|
|
|
/// A list of the inventory nodes loaded. If folders were loaded then only the root folders are
|
|
|
|
/// returned
|
|
|
|
/// </returns>
|
|
|
|
public List<InventoryNodeBase> Execute()
|
2008-09-29 14:55:26 +00:00
|
|
|
{
|
|
|
|
string filePath = "ERROR";
|
|
|
|
int successfulAssetRestores = 0;
|
|
|
|
int failedAssetRestores = 0;
|
2008-10-19 17:51:42 +00:00
|
|
|
int successfulItemRestores = 0;
|
2009-02-11 20:24:41 +00:00
|
|
|
List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>();
|
2009-03-12 06:04:17 +00:00
|
|
|
|
2009-02-12 17:41:09 +00:00
|
|
|
if (!m_userInfo.HasReceivedInventory)
|
2008-10-19 18:19:18 +00:00
|
|
|
{
|
2009-03-12 06:04:17 +00:00
|
|
|
// 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
|
2009-02-12 19:54:19 +00:00
|
|
|
// server.
|
|
|
|
//
|
|
|
|
// FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might
|
|
|
|
// use a remote inventory service, though this is vanishingly rare at the moment.
|
2009-09-06 19:16:56 +00:00
|
|
|
if (null == m_scene.CommsManager.UserAdminService)
|
2009-02-12 19:54:19 +00:00
|
|
|
{
|
|
|
|
m_log.ErrorFormat(
|
|
|
|
"[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1}",
|
|
|
|
m_userInfo.UserProfile.Name, m_userInfo.UserProfile.ID);
|
2009-02-04 00:01:36 +00:00
|
|
|
|
2009-02-12 19:54:19 +00:00
|
|
|
return nodesLoaded;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_userInfo.FetchInventory();
|
2009-06-11 20:50:23 +00:00
|
|
|
for (int i = 0 ; i < 50 ; i++)
|
|
|
|
{
|
|
|
|
if (m_userInfo.HasReceivedInventory == true)
|
|
|
|
break;
|
|
|
|
Thread.Sleep(200);
|
|
|
|
}
|
2009-02-12 19:54:19 +00:00
|
|
|
}
|
2009-02-04 00:01:36 +00:00
|
|
|
}
|
|
|
|
|
2009-02-25 18:07:32 +00:00
|
|
|
InventoryFolderImpl rootDestinationFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath);
|
2008-10-19 18:19:18 +00:00
|
|
|
|
2009-02-25 18:07:32 +00:00
|
|
|
if (null == rootDestinationFolder)
|
2008-10-19 18:19:18 +00:00
|
|
|
{
|
2009-03-04 20:31:03 +00:00
|
|
|
// Possibly provide an option later on to automatically create this folder if it does not exist
|
2009-02-11 18:46:51 +00:00
|
|
|
m_log.ErrorFormat("[INVENTORY ARCHIVER]: Inventory path {0} does not exist", m_invPath);
|
2009-02-04 00:01:36 +00:00
|
|
|
|
2009-02-11 20:24:41 +00:00
|
|
|
return nodesLoaded;
|
2008-10-19 18:19:18 +00:00
|
|
|
}
|
2008-09-29 14:55:26 +00:00
|
|
|
|
2009-02-11 18:46:51 +00:00
|
|
|
archive = new TarArchiveReader(m_loadStream);
|
2009-03-12 06:04:17 +00:00
|
|
|
|
2009-03-04 20:31:03 +00:00
|
|
|
// In order to load identically named folders, we need to keep track of the folders that we have already
|
|
|
|
// created
|
|
|
|
Dictionary <string, InventoryFolderImpl> foldersCreated = new Dictionary<string, InventoryFolderImpl>();
|
2008-09-29 14:55:26 +00:00
|
|
|
|
|
|
|
byte[] data;
|
2009-01-22 16:43:28 +00:00
|
|
|
TarArchiveReader.TarEntryType entryType;
|
2009-01-22 16:43:09 +00:00
|
|
|
while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
|
2008-09-29 14:55:26 +00:00
|
|
|
{
|
2009-03-13 20:46:53 +00:00
|
|
|
if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
|
2008-09-29 14:55:26 +00:00
|
|
|
{
|
|
|
|
if (LoadAsset(filePath, data))
|
|
|
|
successfulAssetRestores++;
|
|
|
|
else
|
|
|
|
failedAssetRestores++;
|
|
|
|
}
|
2009-03-12 06:04:17 +00:00
|
|
|
else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH))
|
2009-03-16 00:12:25 +00:00
|
|
|
{
|
2009-04-24 19:10:13 +00:00
|
|
|
InventoryFolderImpl foundFolder
|
|
|
|
= ReplicateArchivePathToUserInventory(
|
|
|
|
filePath, TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType,
|
|
|
|
rootDestinationFolder, foldersCreated, nodesLoaded);
|
2009-03-12 06:04:17 +00:00
|
|
|
|
2009-03-13 20:46:53 +00:00
|
|
|
if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
|
|
|
|
{
|
2009-04-23 20:15:05 +00:00
|
|
|
InventoryItemBase item = UserInventoryItemSerializer.Deserialize(data);
|
|
|
|
|
|
|
|
// Don't use the item ID that's in the file
|
|
|
|
item.ID = UUID.Random();
|
2009-03-16 00:12:25 +00:00
|
|
|
|
2009-09-06 19:16:56 +00:00
|
|
|
UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.CommsManager);
|
2009-05-05 16:45:21 +00:00
|
|
|
if (UUID.Zero != ospResolvedId)
|
|
|
|
item.CreatorIdAsUuid = ospResolvedId;
|
2009-04-28 17:47:09 +00:00
|
|
|
|
2009-04-23 20:15:05 +00:00
|
|
|
item.Owner = m_userInfo.UserProfile.ID;
|
2009-03-16 00:12:25 +00:00
|
|
|
|
2009-04-23 20:15:05 +00:00
|
|
|
// Reset folder ID to the one in which we want to load it
|
|
|
|
item.Folder = foundFolder.ID;
|
2009-03-13 20:46:53 +00:00
|
|
|
|
2009-04-23 20:15:05 +00:00
|
|
|
m_userInfo.AddItem(item);
|
|
|
|
successfulItemRestores++;
|
2009-03-13 20:46:53 +00:00
|
|
|
|
2009-04-23 20:15:05 +00:00
|
|
|
// If we're loading an item directly into the given destination folder then we need to record
|
|
|
|
// it separately from any loaded root folders
|
|
|
|
if (rootDestinationFolder == foundFolder)
|
|
|
|
nodesLoaded.Add(item);
|
2008-10-19 17:51:42 +00:00
|
|
|
}
|
2008-09-29 14:55:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
archive.Close();
|
|
|
|
|
2009-02-11 18:46:51 +00:00
|
|
|
m_log.DebugFormat("[INVENTORY ARCHIVER]: Restored {0} assets", successfulAssetRestores);
|
|
|
|
m_log.InfoFormat("[INVENTORY ARCHIVER]: Restored {0} items", successfulItemRestores);
|
2009-03-12 06:04:17 +00:00
|
|
|
|
2009-02-11 20:24:41 +00:00
|
|
|
return nodesLoaded;
|
2008-09-29 14:55:26 +00:00
|
|
|
}
|
2009-04-24 19:10:13 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Replicate the inventory paths in the archive to the user's inventory as necessary.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="fsPath"></param>
|
|
|
|
/// <param name="isDir">Is the path we're dealing with a directory?</param>
|
|
|
|
/// <param name="rootDestinationFolder">The root folder for the inventory load</param>
|
|
|
|
/// <param name="foldersCreated">
|
|
|
|
/// The folders created so far. This method will add more folders if necessary
|
|
|
|
/// </param>
|
|
|
|
/// <param name="nodesLoaded">
|
|
|
|
/// Track the inventory nodes created. This is distinct from the folders created since for a particular folder
|
|
|
|
/// chain, only the root node needs to be recorded
|
|
|
|
/// </param>
|
|
|
|
/// <returns>The last user inventory folder created or found for the archive path</returns>
|
|
|
|
public InventoryFolderImpl ReplicateArchivePathToUserInventory(
|
|
|
|
string fsPath,
|
|
|
|
bool isDir,
|
|
|
|
InventoryFolderImpl rootDestinationFolder,
|
|
|
|
Dictionary <string, InventoryFolderImpl> foldersCreated,
|
|
|
|
List<InventoryNodeBase> nodesLoaded)
|
|
|
|
{
|
|
|
|
fsPath = fsPath.Substring(ArchiveConstants.INVENTORY_PATH.Length);
|
|
|
|
|
|
|
|
// Remove the file portion if we aren't already dealing with a directory path
|
|
|
|
if (!isDir)
|
|
|
|
fsPath = fsPath.Remove(fsPath.LastIndexOf("/") + 1);
|
|
|
|
|
|
|
|
string originalFsPath = fsPath;
|
|
|
|
|
|
|
|
m_log.DebugFormat("[INVENTORY ARCHIVER]: Loading to folder {0}", fsPath);
|
|
|
|
|
|
|
|
InventoryFolderImpl foundFolder = null;
|
|
|
|
|
|
|
|
// XXX: Nasty way of dealing with a path that has no directory component
|
|
|
|
if (fsPath.Length > 0)
|
|
|
|
{
|
|
|
|
while (null == foundFolder && fsPath.Length > 0)
|
|
|
|
{
|
|
|
|
if (foldersCreated.ContainsKey(fsPath))
|
|
|
|
{
|
|
|
|
m_log.DebugFormat("[INVENTORY ARCHIVER]: Found previously created fs path {0}", fsPath);
|
|
|
|
foundFolder = foldersCreated[fsPath];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Don't include the last slash
|
|
|
|
int penultimateSlashIndex = fsPath.LastIndexOf("/", fsPath.Length - 2);
|
|
|
|
|
|
|
|
if (penultimateSlashIndex >= 0)
|
|
|
|
{
|
|
|
|
fsPath = fsPath.Remove(penultimateSlashIndex + 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_log.DebugFormat(
|
|
|
|
"[INVENTORY ARCHIVER]: Found no previously created fs path for {0}",
|
|
|
|
originalFsPath);
|
|
|
|
fsPath = string.Empty;
|
|
|
|
foundFolder = rootDestinationFolder;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
foundFolder = rootDestinationFolder;
|
|
|
|
}
|
|
|
|
|
|
|
|
string fsPathSectionToCreate = originalFsPath.Substring(fsPath.Length);
|
|
|
|
string[] rawDirsToCreate
|
|
|
|
= fsPathSectionToCreate.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
while (i < rawDirsToCreate.Length)
|
|
|
|
{
|
|
|
|
m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawDirsToCreate[i]);
|
|
|
|
|
|
|
|
int identicalNameIdentifierIndex
|
|
|
|
= rawDirsToCreate[i].LastIndexOf(
|
|
|
|
ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR);
|
|
|
|
string folderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex);
|
|
|
|
|
|
|
|
UUID newFolderId = UUID.Random();
|
|
|
|
m_userInfo.CreateFolder(
|
|
|
|
folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID);
|
2009-08-11 16:49:52 +00:00
|
|
|
|
|
|
|
m_log.DebugFormat("[INVENTORY ARCHIVER]: Retrieving newly created folder {0}", folderName);
|
2009-04-24 19:10:13 +00:00
|
|
|
foundFolder = foundFolder.GetChildFolder(newFolderId);
|
2009-08-11 16:49:52 +00:00
|
|
|
m_log.DebugFormat(
|
|
|
|
"[INVENTORY ARCHIVER]: Retrieved newly created folder {0} with ID {1}",
|
|
|
|
foundFolder.Name, foundFolder.ID);
|
2009-04-24 19:10:13 +00:00
|
|
|
|
|
|
|
// Record that we have now created this folder
|
|
|
|
fsPath += rawDirsToCreate[i] + "/";
|
|
|
|
m_log.DebugFormat("[INVENTORY ARCHIVER]: Recording creation of fs path {0}", fsPath);
|
|
|
|
foldersCreated[fsPath] = foundFolder;
|
|
|
|
|
|
|
|
if (0 == i)
|
|
|
|
nodesLoaded.Add(foundFolder);
|
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return foundFolder;
|
|
|
|
|
|
|
|
/*
|
|
|
|
string[] rawFolders = filePath.Split(new char[] { '/' });
|
|
|
|
|
|
|
|
// Find the folders that do exist along the path given
|
|
|
|
int i = 0;
|
|
|
|
bool noFolder = false;
|
|
|
|
InventoryFolderImpl foundFolder = rootDestinationFolder;
|
|
|
|
while (!noFolder && i < rawFolders.Length)
|
|
|
|
{
|
|
|
|
InventoryFolderImpl folder = foundFolder.FindFolderByPath(rawFolders[i]);
|
|
|
|
if (null != folder)
|
|
|
|
{
|
|
|
|
m_log.DebugFormat("[INVENTORY ARCHIVER]: Found folder {0}", folder.Name);
|
|
|
|
foundFolder = folder;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
noFolder = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create any folders that did not previously exist
|
|
|
|
while (i < rawFolders.Length)
|
|
|
|
{
|
|
|
|
m_log.DebugFormat("[INVENTORY ARCHIVER]: Creating folder {0}", rawFolders[i]);
|
|
|
|
|
|
|
|
UUID newFolderId = UUID.Random();
|
|
|
|
m_userInfo.CreateFolder(
|
|
|
|
rawFolders[i++], newFolderId, (ushort)AssetType.Folder, foundFolder.ID);
|
|
|
|
foundFolder = foundFolder.GetChildFolder(newFolderId);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
}
|
2008-09-29 14:55:26 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Load an asset
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="assetFilename"></param>
|
|
|
|
/// <param name="data"></param>
|
|
|
|
/// <returns>true if asset was successfully loaded, false otherwise</returns>
|
|
|
|
private bool LoadAsset(string assetPath, byte[] data)
|
|
|
|
{
|
2008-09-29 15:33:58 +00:00
|
|
|
//IRegionSerialiser serialiser = scene.RequestModuleInterface<IRegionSerialiser>();
|
2008-09-29 14:55:26 +00:00
|
|
|
// Right now we're nastily obtaining the UUID from the filename
|
2009-03-12 06:04:17 +00:00
|
|
|
string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length);
|
|
|
|
int i = filename.LastIndexOf(ArchiveConstants.ASSET_EXTENSION_SEPARATOR);
|
2008-09-29 14:55:26 +00:00
|
|
|
|
|
|
|
if (i == -1)
|
|
|
|
{
|
|
|
|
m_log.ErrorFormat(
|
2009-02-11 18:46:51 +00:00
|
|
|
"[INVENTORY ARCHIVER]: Could not find extension information in asset path {0} since it's missing the separator {1}. Skipping",
|
2009-03-12 06:04:17 +00:00
|
|
|
assetPath, ArchiveConstants.ASSET_EXTENSION_SEPARATOR);
|
2008-09-29 14:55:26 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
string extension = filename.Substring(i);
|
|
|
|
string uuid = filename.Remove(filename.Length - extension.Length);
|
|
|
|
|
2009-03-12 06:04:17 +00:00
|
|
|
if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension))
|
2008-09-29 14:55:26 +00:00
|
|
|
{
|
2009-03-12 06:04:17 +00:00
|
|
|
sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];
|
2008-09-29 14:55:26 +00:00
|
|
|
|
2009-02-25 20:07:25 +00:00
|
|
|
//m_log.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType);
|
2008-09-29 14:55:26 +00:00
|
|
|
|
|
|
|
AssetBase asset = new AssetBase(new UUID(uuid), "RandomName");
|
|
|
|
|
2009-02-17 01:36:44 +00:00
|
|
|
asset.Type = assetType;
|
2008-09-29 14:55:26 +00:00
|
|
|
asset.Data = data;
|
|
|
|
|
2009-09-06 19:16:56 +00:00
|
|
|
m_scene.AssetService.Store(asset);
|
2008-09-29 14:55:26 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_log.ErrorFormat(
|
2009-02-11 18:46:51 +00:00
|
|
|
"[INVENTORY ARCHIVER]: Tried to dearchive data with path {0} with an unknown type extension {1}",
|
2008-09-29 14:55:26 +00:00
|
|
|
assetPath, extension);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-09-29 15:14:57 +00:00
|
|
|
}
|