Migrate assets from chained asset service to xassetservice as they are requested.
This shrinks the asset database over time as duplicate assets are fetched.user_profiles
parent
d05af4bdad
commit
bd0c1d9b6a
|
@ -106,10 +106,19 @@ namespace OpenSim.Services.AssetService
|
||||||
AssetBase asset = m_Database.GetAsset(assetID);
|
AssetBase asset = m_Database.GetAsset(assetID);
|
||||||
|
|
||||||
if (asset != null)
|
if (asset != null)
|
||||||
|
{
|
||||||
return asset;
|
return asset;
|
||||||
|
}
|
||||||
else if (HasChainedAssetService)
|
else if (HasChainedAssetService)
|
||||||
return m_ChainedAssetService.Get(id);
|
{
|
||||||
else
|
asset = m_ChainedAssetService.Get(id);
|
||||||
|
|
||||||
|
if (asset != null)
|
||||||
|
MigrateFromChainedService(asset);
|
||||||
|
|
||||||
|
return asset;
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -128,41 +137,22 @@ namespace OpenSim.Services.AssetService
|
||||||
{
|
{
|
||||||
// m_log.DebugFormat("[XASSET SERVICE]: Get asset metadata for {0}", id);
|
// m_log.DebugFormat("[XASSET SERVICE]: Get asset metadata for {0}", id);
|
||||||
|
|
||||||
UUID assetID;
|
AssetBase asset = Get(id);
|
||||||
|
|
||||||
if (!UUID.TryParse(id, out assetID))
|
|
||||||
return null;
|
|
||||||
|
|
||||||
AssetBase asset = m_Database.GetAsset(assetID);
|
|
||||||
if (asset != null)
|
if (asset != null)
|
||||||
{
|
|
||||||
return asset.Metadata;
|
return asset.Metadata;
|
||||||
}
|
|
||||||
else if (HasChainedAssetService)
|
|
||||||
{
|
|
||||||
return m_ChainedAssetService.GetMetadata(id);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public virtual byte[] GetData(string id)
|
public virtual byte[] GetData(string id)
|
||||||
{
|
{
|
||||||
// m_log.DebugFormat("[XASSET SERVICE]: Get asset data for {0}", id);
|
// m_log.DebugFormat("[XASSET SERVICE]: Get asset data for {0}", id);
|
||||||
|
|
||||||
UUID assetID;
|
AssetBase asset = Get(id);
|
||||||
|
|
||||||
if (!UUID.TryParse(id, out assetID))
|
|
||||||
return null;
|
|
||||||
|
|
||||||
AssetBase asset = m_Database.GetAsset(assetID);
|
|
||||||
|
|
||||||
if (asset != null)
|
if (asset != null)
|
||||||
return asset.Data;
|
return asset.Data;
|
||||||
else if (HasChainedAssetService)
|
|
||||||
return m_ChainedAssetService.GetData(id);
|
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -176,10 +166,7 @@ namespace OpenSim.Services.AssetService
|
||||||
if (!UUID.TryParse(id, out assetID))
|
if (!UUID.TryParse(id, out assetID))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
AssetBase asset = m_Database.GetAsset(assetID);
|
AssetBase asset = Get(id);
|
||||||
|
|
||||||
if (asset == null && HasChainedAssetService)
|
|
||||||
asset = m_ChainedAssetService.Get(id);
|
|
||||||
|
|
||||||
//m_log.DebugFormat("[XASSET SERVICE]: Got asset {0}", asset);
|
//m_log.DebugFormat("[XASSET SERVICE]: Got asset {0}", asset);
|
||||||
|
|
||||||
|
@ -223,5 +210,10 @@ namespace OpenSim.Services.AssetService
|
||||||
|
|
||||||
return m_Database.Delete(id);
|
return m_Database.Delete(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void MigrateFromChainedService(AssetBase asset)
|
||||||
|
{
|
||||||
|
Util.FireAndForget(o => { Store(asset); m_ChainedAssetService.Delete(asset.ID); });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue