on get asset with callback, do the callback even if asset not found. This is needed on same cases

melanie
UbitUmarov 2016-11-03 16:56:09 +00:00
parent 4b326f8691
commit d2e380e81e
1 changed files with 18 additions and 35 deletions

View File

@ -347,51 +347,34 @@ namespace OpenSim.Services.Connectors
string uri = r.uri; string uri = r.uri;
string id = r.id; string id = r.id;
bool success = false;
try try
{ {
AssetBase a = SynchronousRestObjectRequester.MakeRequest<int, AssetBase>("GET", uri, 0, 30000, m_Auth); AssetBase a = SynchronousRestObjectRequester.MakeRequest<int, AssetBase>("GET", uri, 0, 30000, m_Auth);
if (a != null)
if (a != null && m_Cache != null)
m_Cache.Cache(a);
List<AssetRetrievedEx> handlers;
lock (m_AssetHandlers)
{ {
if (m_Cache != null) handlers = m_AssetHandlers[id];
m_Cache.Cache(a); m_AssetHandlers.Remove(id);
}
List<AssetRetrievedEx> handlers; if(handlers != null)
lock (m_AssetHandlers) {
Util.FireAndForget(x =>
{ {
handlers = m_AssetHandlers[id]; foreach (AssetRetrievedEx h in handlers)
m_AssetHandlers.Remove(id);
}
if(handlers != null)
{
Util.FireAndForget(x =>
{ {
foreach (AssetRetrievedEx h in handlers) try { h.Invoke(a); }
{ catch { }
try { h.Invoke(a); } }
catch { }
}
handlers.Clear();
});
}
success = true;
}
}
finally
{
if (!success)
{
List<AssetRetrievedEx> handlers;
lock (m_AssetHandlers)
{
handlers = m_AssetHandlers[id];
m_AssetHandlers.Remove(id);
}
if (handlers != null)
handlers.Clear(); handlers.Clear();
});
} }
} }
catch { }
} }
} }