aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/AssetService
diff options
context:
space:
mode:
authorOren Hurvitz2014-03-31 11:53:12 +0300
committerOren Hurvitz2014-04-02 06:30:57 +0100
commitd1c3f8eef58b29eb8760eeb1ac03852a2387f927 (patch)
treeb8686f4ea01b6dac3740b9685734686e2178dd2d /OpenSim/Services/AssetService
parentfix orphaned code in sun module per mantis 7068 (diff)
downloadopensim-SC_OLD-d1c3f8eef58b29eb8760eeb1ac03852a2387f927.zip
opensim-SC_OLD-d1c3f8eef58b29eb8760eeb1ac03852a2387f927.tar.gz
opensim-SC_OLD-d1c3f8eef58b29eb8760eeb1ac03852a2387f927.tar.bz2
opensim-SC_OLD-d1c3f8eef58b29eb8760eeb1ac03852a2387f927.tar.xz
Added assets service method AssetsExist(), which returns whether the given list of assets exist.
This method is used to optimize sending assets with embedded assets: e.g., when a Hypergrid visitor takes an item into the inventory.
Diffstat (limited to 'OpenSim/Services/AssetService')
-rw-r--r--OpenSim/Services/AssetService/AssetService.cs19
-rw-r--r--OpenSim/Services/AssetService/XAssetService.cs11
2 files changed, 26 insertions, 4 deletions
diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs
index 08fd3f8..0aefa16 100644
--- a/OpenSim/Services/AssetService/AssetService.cs
+++ b/OpenSim/Services/AssetService/AssetService.cs
@@ -153,9 +153,24 @@ namespace OpenSim.Services.AssetService
153 return true; 153 return true;
154 } 154 }
155 155
156 public virtual bool[] AssetsExist(string[] ids)
157 {
158 try
159 {
160 UUID[] uuid = Array.ConvertAll(ids, id => UUID.Parse(id));
161 return m_Database.AssetsExist(uuid);
162 }
163 catch (Exception e)
164 {
165 m_log.Error("[ASSET SERVICE]: Exception getting assets ", e);
166 return new bool[ids.Length];
167 }
168 }
169
156 public virtual string Store(AssetBase asset) 170 public virtual string Store(AssetBase asset)
157 { 171 {
158 if (!m_Database.ExistsAsset(asset.FullID)) 172 bool exists = m_Database.AssetsExist(new[] { asset.FullID })[0];
173 if (!exists)
159 { 174 {
160// m_log.DebugFormat( 175// m_log.DebugFormat(
161// "[ASSET SERVICE]: Storing asset {0} {1}, bytes {2}", asset.Name, asset.FullID, asset.Data.Length); 176// "[ASSET SERVICE]: Storing asset {0} {1}, bytes {2}", asset.Name, asset.FullID, asset.Data.Length);
@@ -186,4 +201,4 @@ namespace OpenSim.Services.AssetService
186 return m_Database.Delete(id); 201 return m_Database.Delete(id);
187 } 202 }
188 } 203 }
189} \ No newline at end of file 204}
diff --git a/OpenSim/Services/AssetService/XAssetService.cs b/OpenSim/Services/AssetService/XAssetService.cs
index 6047616..f58b769 100644
--- a/OpenSim/Services/AssetService/XAssetService.cs
+++ b/OpenSim/Services/AssetService/XAssetService.cs
@@ -175,9 +175,16 @@ namespace OpenSim.Services.AssetService
175 return true; 175 return true;
176 } 176 }
177 177
178 public virtual bool[] AssetsExist(string[] ids)
179 {
180 UUID[] uuid = Array.ConvertAll(ids, id => UUID.Parse(id));
181 return m_Database.AssetsExist(uuid);
182 }
183
178 public virtual string Store(AssetBase asset) 184 public virtual string Store(AssetBase asset)
179 { 185 {
180 if (!m_Database.ExistsAsset(asset.FullID)) 186 bool exists = m_Database.AssetsExist(new[] { asset.FullID })[0];
187 if (!exists)
181 { 188 {
182// m_log.DebugFormat( 189// m_log.DebugFormat(
183// "[XASSET SERVICE]: Storing asset {0} {1}, bytes {2}", asset.Name, asset.FullID, asset.Data.Length); 190// "[XASSET SERVICE]: Storing asset {0} {1}, bytes {2}", asset.Name, asset.FullID, asset.Data.Length);
@@ -217,4 +224,4 @@ namespace OpenSim.Services.AssetService
217 m_ChainedAssetService.Delete(asset.ID); 224 m_ChainedAssetService.Delete(asset.ID);
218 } 225 }
219 } 226 }
220} \ No newline at end of file 227}