* move command line parsing code from inventory archive modules to opensim server
* use default inventory archive name if none is given * other minor cleanups * this facility is not useable yet0.6.0-stable
parent
ed8a20dd60
commit
f7205da1d9
|
@ -686,7 +686,7 @@ namespace OpenSim
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Save inventory to a file.
|
/// Save inventory to a file archive
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cmdparams"></param>
|
/// <param name="cmdparams"></param>
|
||||||
protected void SaveInv(string[] cmdparams)
|
protected void SaveInv(string[] cmdparams)
|
||||||
|
@ -697,11 +697,19 @@ namespace OpenSim
|
||||||
m_log.Error("[CONSOLE]: usage is save-inv <first name> <last name> <inventory path> [<save file path>]");
|
m_log.Error("[CONSOLE]: usage is save-inv <first name> <last name> <inventory path> [<save file path>]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
new InventoryArchiveWriteRequest(m_sceneManager.CurrentOrFirstScene,m_commsManager).execute(cmdparams);
|
|
||||||
|
string firstName = cmdparams[0];
|
||||||
|
string lastName = cmdparams[1];
|
||||||
|
string invPath = cmdparams[2];
|
||||||
|
string savePath = (cmdparams.Length > 3 ? cmdparams[3] : DEFAULT_INV_BACKUP_FILENAME);
|
||||||
|
|
||||||
|
new InventoryArchiveWriteRequest(
|
||||||
|
m_sceneManager.CurrentOrFirstScene,m_commsManager).execute(
|
||||||
|
firstName, lastName, invPath, savePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Load inventory from a tar.gz file.
|
/// Load inventory from an inventory file archive
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cmdparams"></param>
|
/// <param name="cmdparams"></param>
|
||||||
protected void LoadInv(string[] cmdparams)
|
protected void LoadInv(string[] cmdparams)
|
||||||
|
@ -712,7 +720,15 @@ namespace OpenSim
|
||||||
m_log.Error("[CONSOLE]: usage is load-inv <first name> <last name> <inventory path> [<load file path>]");
|
m_log.Error("[CONSOLE]: usage is load-inv <first name> <last name> <inventory path> [<load file path>]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
new InventoryArchiveReadRequest(m_sceneManager.CurrentOrFirstScene, m_commsManager).execute(cmdparams);
|
|
||||||
|
string firstName = cmdparams[0];
|
||||||
|
string lastName = cmdparams[1];
|
||||||
|
string invPath = cmdparams[2];
|
||||||
|
string loadPath = (cmdparams.Length > 3 ? cmdparams[3] : DEFAULT_INV_BACKUP_FILENAME);
|
||||||
|
|
||||||
|
new InventoryArchiveReadRequest(
|
||||||
|
m_sceneManager.CurrentOrFirstScene, m_commsManager).execute(
|
||||||
|
firstName, lastName, invPath, loadPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -45,14 +45,15 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver
|
||||||
{
|
{
|
||||||
public class InventoryArchiveReadRequest
|
public class InventoryArchiveReadRequest
|
||||||
{
|
{
|
||||||
|
private static ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
protected Scene scene;
|
protected Scene scene;
|
||||||
protected TarArchiveReader archive;
|
protected TarArchiveReader archive;
|
||||||
private static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding();
|
private static System.Text.ASCIIEncoding m_asciiEncoding = new System.Text.ASCIIEncoding();
|
||||||
ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
CachedUserInfo userInfo;
|
CachedUserInfo userInfo;
|
||||||
UserProfileData userProfile;
|
UserProfileData userProfile;
|
||||||
CommunicationsManager commsManager;
|
CommunicationsManager commsManager;
|
||||||
string loadPath;
|
|
||||||
|
|
||||||
public InventoryArchiveReadRequest(Scene currentScene, CommunicationsManager commsManager)
|
public InventoryArchiveReadRequest(Scene currentScene, CommunicationsManager commsManager)
|
||||||
{
|
{
|
||||||
|
@ -142,22 +143,17 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute(string[] cmdparams)
|
public void execute(string firstName, string lastName, string invPath, string loadPath)
|
||||||
{
|
{
|
||||||
string filePath = "ERROR";
|
string filePath = "ERROR";
|
||||||
int successfulAssetRestores = 0;
|
int successfulAssetRestores = 0;
|
||||||
int failedAssetRestores = 0;
|
int failedAssetRestores = 0;
|
||||||
|
int successfulItemRestores = 0;
|
||||||
string firstName = cmdparams[0];
|
|
||||||
string lastName = cmdparams[1];
|
|
||||||
//string invPath = cmdparams[2];
|
|
||||||
loadPath = (cmdparams.Length > 3 ? cmdparams[3] : "inventory.tar.gz");
|
|
||||||
|
|
||||||
archive
|
archive
|
||||||
= new TarArchiveReader(new GZipStream(
|
= new TarArchiveReader(new GZipStream(
|
||||||
new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress));
|
new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress));
|
||||||
|
|
||||||
|
|
||||||
userProfile = commsManager.UserService.GetUserProfile(firstName, lastName);
|
userProfile = commsManager.UserService.GetUserProfile(firstName, lastName);
|
||||||
userInfo = commsManager.UserProfileCacheService.GetUserDetails(userProfile.ID);
|
userInfo = commsManager.UserProfileCacheService.GetUserDetails(userProfile.ID);
|
||||||
|
|
||||||
|
@ -175,13 +171,18 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver
|
||||||
{
|
{
|
||||||
//Load the item
|
//Load the item
|
||||||
InventoryItemBase item = loadInvItem(filePath, m_asciiEncoding.GetString(data));
|
InventoryItemBase item = loadInvItem(filePath, m_asciiEncoding.GetString(data));
|
||||||
if (item != null) userInfo.AddItem(item);
|
if (item != null)
|
||||||
|
{
|
||||||
|
userInfo.AddItem(item);
|
||||||
|
successfulItemRestores++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
archive.Close();
|
archive.Close();
|
||||||
|
|
||||||
m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores);
|
m_log.DebugFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores);
|
||||||
|
m_log.InfoFormat("[ARCHIVER]: Restored {0} items", successfulItemRestores);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -41,15 +41,20 @@ using log4net;
|
||||||
|
|
||||||
|
|
||||||
namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver
|
namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver
|
||||||
{
|
{
|
||||||
public class InventoryArchiveWriteRequest
|
public class InventoryArchiveWriteRequest
|
||||||
{
|
{
|
||||||
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
protected Scene scene;
|
protected Scene scene;
|
||||||
protected TarArchiveWriter archive;
|
protected TarArchiveWriter archive;
|
||||||
protected CommunicationsManager commsManager;
|
protected CommunicationsManager commsManager;
|
||||||
Dictionary<UUID, int> assetUuids;
|
Dictionary<UUID, int> assetUuids;
|
||||||
string savePath;
|
|
||||||
|
/// <value>
|
||||||
|
/// The path to which the inventory archive will be saved.
|
||||||
|
/// </value>
|
||||||
|
private string m_savePath;
|
||||||
|
|
||||||
public InventoryArchiveWriteRequest(Scene currentScene, CommunicationsManager commsManager)
|
public InventoryArchiveWriteRequest(Scene currentScene, CommunicationsManager commsManager)
|
||||||
{
|
{
|
||||||
|
@ -63,7 +68,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver
|
||||||
{
|
{
|
||||||
AssetsArchiver assetsArchiver = new AssetsArchiver(assetsFound);
|
AssetsArchiver assetsArchiver = new AssetsArchiver(assetsFound);
|
||||||
assetsArchiver.Archive(archive);
|
assetsArchiver.Archive(archive);
|
||||||
archive.WriteTar(new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress));
|
archive.WriteTar(new GZipStream(new FileStream(m_savePath, FileMode.Create), CompressionMode.Compress));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void saveInvItem(InventoryItemBase inventoryItem, string path)
|
protected void saveInvItem(InventoryItemBase inventoryItem, string path)
|
||||||
|
@ -156,15 +161,10 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute(string[] cmdparams)
|
public void execute(string firstName, string lastName, string invPath, string savePath)
|
||||||
{
|
{
|
||||||
ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
m_savePath = savePath;
|
||||||
|
|
||||||
string firstName = cmdparams[0];
|
|
||||||
string lastName = cmdparams[1];
|
|
||||||
string invPath = cmdparams[2];
|
|
||||||
savePath = (cmdparams.Length > 3 ? cmdparams[3] : "inventory.tar.gz");
|
|
||||||
|
|
||||||
UserProfileData userProfile = commsManager.UserService.GetUserProfile(firstName, lastName);
|
UserProfileData userProfile = commsManager.UserService.GetUserProfile(firstName, lastName);
|
||||||
if (null == userProfile)
|
if (null == userProfile)
|
||||||
{
|
{
|
||||||
|
@ -242,8 +242,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Archiver
|
||||||
}
|
}
|
||||||
|
|
||||||
new AssetsRequest(assetUuids.Keys, scene.AssetCache, ReceivedAllAssets).Execute();
|
new AssetsRequest(assetUuids.Keys, scene.AssetCache, ReceivedAllAssets).Execute();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue