Better error-handling when storing assets: recognize that 'null' is an error value
parent
52f8669169
commit
3f76f72137
|
@ -143,7 +143,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
|
||||||
asset1.Data = asset.Data;
|
asset1.Data = asset.Data;
|
||||||
|
|
||||||
string id = m_scene.AssetService.Store(asset1);
|
string id = m_scene.AssetService.Store(asset1);
|
||||||
if (id == string.Empty)
|
if (String.IsNullOrEmpty(id))
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("[HG ASSET MAPPER]: Failed to post asset {0} to asset server {1}: the server did not accept the asset", asset.ID, url);
|
m_log.DebugFormat("[HG ASSET MAPPER]: Failed to post asset {0} to asset server {1}: the server did not accept the asset", asset.ID, url);
|
||||||
success = false;
|
success = false;
|
||||||
|
|
|
@ -346,7 +346,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
|
||||||
return asset.ID;
|
return asset.ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
string id = string.Empty;
|
string id;
|
||||||
if (IsHG(asset.ID))
|
if (IsHG(asset.ID))
|
||||||
{
|
{
|
||||||
if (m_AssetPerms.AllowedExport(asset.Type))
|
if (m_AssetPerms.AllowedExport(asset.Type))
|
||||||
|
@ -357,18 +357,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset
|
||||||
else
|
else
|
||||||
id = m_GridService.Store(asset);
|
id = m_GridService.Store(asset);
|
||||||
|
|
||||||
if (id != String.Empty)
|
if (String.IsNullOrEmpty(id))
|
||||||
{
|
return string.Empty;
|
||||||
// Placing this here, so that this work with old asset servers that don't send any reply back
|
|
||||||
// SynchronousRestObjectRequester returns somethins that is not an empty string
|
asset.ID = id;
|
||||||
if (id != null)
|
|
||||||
asset.ID = id;
|
if (m_Cache != null)
|
||||||
|
m_Cache.Cache(asset);
|
||||||
|
|
||||||
if (m_Cache != null)
|
|
||||||
m_Cache.Cache(asset);
|
|
||||||
}
|
|
||||||
return id;
|
return id;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool UpdateContent(string id, byte[] data)
|
public bool UpdateContent(string id, byte[] data)
|
||||||
|
|
|
@ -221,7 +221,7 @@ namespace OpenSim.Services.Connectors
|
||||||
AsynchronousRestObjectRequester.MakeRequest<int, AssetBase>("GET", uri, 0,
|
AsynchronousRestObjectRequester.MakeRequest<int, AssetBase>("GET", uri, 0,
|
||||||
delegate(AssetBase a)
|
delegate(AssetBase a)
|
||||||
{
|
{
|
||||||
if (m_Cache != null)
|
if (a != null && m_Cache != null)
|
||||||
m_Cache.Cache(a);
|
m_Cache.Cache(a);
|
||||||
|
|
||||||
AssetRetrievedEx handlers;
|
AssetRetrievedEx handlers;
|
||||||
|
@ -287,7 +287,7 @@ namespace OpenSim.Services.Connectors
|
||||||
|
|
||||||
string uri = m_ServerURI + "/assets/";
|
string uri = m_ServerURI + "/assets/";
|
||||||
|
|
||||||
string newID = string.Empty;
|
string newID;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
newID = SynchronousRestObjectRequester.
|
newID = SynchronousRestObjectRequester.
|
||||||
|
@ -295,19 +295,18 @@ namespace OpenSim.Services.Connectors
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
m_log.WarnFormat("[ASSET CONNECTOR]: Unable to send asset {0} to asset server. Reason: {1}", asset.ID, e.Message);
|
m_log.Warn(string.Format("[ASSET CONNECTOR]: Unable to send asset {0} to asset server. Reason: {1} ", asset.ID, e.Message), e);
|
||||||
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newID != String.Empty)
|
if (string.IsNullOrEmpty(newID))
|
||||||
{
|
return string.Empty;
|
||||||
// Placing this here, so that this work with old asset servers that don't send any reply back
|
|
||||||
// SynchronousRestObjectRequester returns somethins that is not an empty string
|
asset.ID = newID;
|
||||||
if (newID != null)
|
|
||||||
asset.ID = newID;
|
if (m_Cache != null)
|
||||||
|
m_Cache.Cache(asset);
|
||||||
|
|
||||||
if (m_Cache != null)
|
|
||||||
m_Cache.Cache(asset);
|
|
||||||
}
|
|
||||||
return newID;
|
return newID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ namespace OpenSim.Services.Interfaces
|
||||||
/// Returns a random ID if none is passed via the asset argument.
|
/// Returns a random ID if none is passed via the asset argument.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <param name="asset"></param>
|
/// <param name="asset"></param>
|
||||||
/// <returns></returns>
|
/// <returns>The Asset ID, or string.Empty if an error occurred</returns>
|
||||||
string Store(AssetBase asset);
|
string Store(AssetBase asset);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue